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

xtensa: ISS: Use kmalloc_array() in simdisk_init()

* A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
to make the corresponding size determination a bit safer according to
the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>

authored by

Markus Elfring and committed by
Max Filippov
5e78e465 c32537d4

+1 -2
+1 -2
arch/xtensa/platforms/iss/simdisk.c
··· 317 317 if (simdisk_count > MAX_SIMDISK_COUNT) 318 318 simdisk_count = MAX_SIMDISK_COUNT; 319 319 320 - sddev = kmalloc(simdisk_count * sizeof(struct simdisk), 321 - GFP_KERNEL); 320 + sddev = kmalloc_array(simdisk_count, sizeof(*sddev), GFP_KERNEL); 322 321 if (sddev == NULL) 323 322 goto out_unregister; 324 323