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

clk/Renesas-MSTP: Use kmalloc_array() in cpg_mstp_clocks_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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

authored by

Markus Elfring and committed by
Stephen Boyd
0637a4c7 faabbe50

+1 -1
+1 -1
drivers/clk/renesas/clk-mstp.c
··· 167 167 unsigned int i; 168 168 169 169 group = kzalloc(sizeof(*group), GFP_KERNEL); 170 - clks = kmalloc(MSTP_MAX_CLOCKS * sizeof(*clks), GFP_KERNEL); 170 + clks = kmalloc_array(MSTP_MAX_CLOCKS, sizeof(*clks), GFP_KERNEL); 171 171 if (group == NULL || clks == NULL) { 172 172 kfree(group); 173 173 kfree(clks);