Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drivers/memstick/core/mspro_block.c: fix attributes array allocation

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>

authored by

Michal Nazarewicz and committed by
Linus Torvalds
be2d3f97 1a10bd94

+2 -2
+2 -2
drivers/memstick/core/mspro_block.c
··· 1023 1023 } else 1024 1024 attr_count = attr->count; 1025 1025 1026 - msb->attr_group.attrs = kzalloc((attr_count + 1) 1027 - * sizeof(struct attribute), 1026 + msb->attr_group.attrs = kcalloc(attr_count + 1, 1027 + sizeof(*msb->attr_group.attrs), 1028 1028 GFP_KERNEL); 1029 1029 if (!msb->attr_group.attrs) { 1030 1030 rc = -ENOMEM;