[<prev] [next>] [day] [month] [year] [list]
Message-Id: <04eadffca1bf860e2edc66cc372c36cac1e8b668.1382697178.git.mina86@mina86.com>
Date: Fri, 25 Oct 2013 11:36:28 +0100
From: Michal Nazarewicz <mpn@...gle.com>
To: Andrew Morton <akpm@...ux-foundation.org>,
Tejun Heo <tj@...nel.org>, Al Viro <viro@...iv.linux.org.uk>
Cc: linux-kernel@...r.kernel.org, Michal Nazarewicz <mina86@...a86.com>
Subject: [PATCH] drivers: mspro: fix attributes array allocation
From: Michal Nazarewicz <mina86@...a86.com>
attrs field of attribute_group structure is a pointer to a pointer
(as in an array of pointers) rather than pointer to attribute
struct (as in an array of structures), so when allocating size
of the pointer sholud be used instead of the structure it is
pointing to.
While at it, also change the call to use kcalloc rather than
kzalloc.
Signed-off-by: Michal Nazarewicz <mina86@...a86.com>
---
drivers/memstick/core/mspro_block.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c
index f4176ca..fc145d2 100644
--- a/drivers/memstick/core/mspro_block.c
+++ b/drivers/memstick/core/mspro_block.c
@@ -1023,8 +1023,8 @@ static int mspro_block_read_attributes(struct memstick_dev *card)
} else
attr_count = attr->count;
- msb->attr_group.attrs = kzalloc((attr_count + 1)
- * sizeof(struct attribute),
+ msb->attr_group.attrs = kcalloc(attr_count + 1,
+ sizeof(*msb->attr_group.attrs),
GFP_KERNEL);
if (!msb->attr_group.attrs) {
rc = -ENOMEM;
--
1.8.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists