Skip to content

Commit

Permalink
drivers/memstick/core/mspro_block.c: fix attributes array allocation
Browse files Browse the repository at this point in the history
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>
Cc: Tejun Heo <tj@kernel.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Alex Dubov <oakad@yahoo.com>
Cc: Maxim Levitsky <maximlevitsky@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Michal Nazarewicz authored and Linus Torvalds committed Nov 13, 2013
1 parent 1a10bd9 commit be2d3f9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/memstick/core/mspro_block.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit be2d3f9

Please sign in to comment.