linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers: mspro: fix attributes array allocation
@ 2013-10-25 10:36 Michal Nazarewicz
  0 siblings, 0 replies; only message in thread
From: Michal Nazarewicz @ 2013-10-25 10:36 UTC (permalink / raw)
  To: Andrew Morton, Tejun Heo, Al Viro; +Cc: linux-kernel, Michal Nazarewicz

From: Michal Nazarewicz <mina86@mina86.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@mina86.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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2013-10-25 10:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-25 10:36 [PATCH] drivers: mspro: fix attributes array allocation Michal Nazarewicz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).