pinctrl: microchip-sgpio: use kcalloc() instead of kzalloc()

Use devm_kcalloc() in microchip_sgpio_register_bank() 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>
Link: https://lore.kernel.org/20250819143935.372084-2-rongqianfeng@vivo.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
Qianfeng Rong 2025-08-19 22:39:32 +08:00 committed by Linus Walleij
parent b8dc230254
commit 2092b3b278

View File

@ -824,7 +824,7 @@ static int microchip_sgpio_register_bank(struct device *dev,
pctl_desc->confops = &sgpio_confops;
pctl_desc->owner = THIS_MODULE;
pins = devm_kzalloc(dev, sizeof(*pins)*ngpios, GFP_KERNEL);
pins = devm_kcalloc(dev, ngpios, sizeof(*pins), GFP_KERNEL);
if (!pins)
return -ENOMEM;