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

target: Use kmalloc_array() in transport_kmap_data_sg()

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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>

authored by

Markus Elfring and committed by
Nicholas Bellinger
df6751f3 f318aef5

+1 -1
+1 -1
drivers/target/target_core_transport.c
··· 2311 2311 return kmap(sg_page(sg)) + sg->offset; 2312 2312 2313 2313 /* >1 page. use vmap */ 2314 - pages = kmalloc(sizeof(*pages) * cmd->t_data_nents, GFP_KERNEL); 2314 + pages = kmalloc_array(cmd->t_data_nents, sizeof(*pages), GFP_KERNEL); 2315 2315 if (!pages) 2316 2316 return NULL; 2317 2317