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

Configure Feed

Select the types of activity you want to include in your feed.

pinctrl: sunxi: use kcalloc() instead of kzalloc()

Use devm_kcalloc() in init_pins_table() and prepare_function_table() to
gain built-in overflow protection, making memory allocation safer when
calculating allocation size compared to explicit multiplication.

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Link: https://lore.kernel.org/20250819143935.372084-5-rongqianfeng@vivo.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Qianfeng Rong and committed by
Linus Walleij
a90d6f4a 42311ea5

+2 -2
+2 -2
drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c
··· 103 103 return ERR_PTR(-EINVAL); 104 104 } 105 105 106 - pins = devm_kzalloc(dev, desc->npins * sizeof(*pins), GFP_KERNEL); 106 + pins = devm_kcalloc(dev, desc->npins, sizeof(*pins), GFP_KERNEL); 107 107 if (!pins) 108 108 return ERR_PTR(-ENOMEM); 109 109 ··· 199 199 * Allocate the memory needed for the functions in one table. 200 200 * We later use pointers into this table to mark each pin. 201 201 */ 202 - func = devm_kzalloc(dev, num_funcs * sizeof(*func), GFP_KERNEL); 202 + func = devm_kcalloc(dev, num_funcs, sizeof(*func), GFP_KERNEL); 203 203 if (!func) 204 204 return -ENOMEM; 205 205