From: Qianfeng Rong Date: Tue, 19 Aug 2025 14:39:32 +0000 (+0800) Subject: pinctrl: microchip-sgpio: use kcalloc() instead of kzalloc() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=2092b3b278be03f73a2438a9d14e2ac472eec033;p=users%2Fjedix%2Flinux-maple.git 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 Link: https://lore.kernel.org/20250819143935.372084-2-rongqianfeng@vivo.com Signed-off-by: Linus Walleij --- diff --git a/drivers/pinctrl/pinctrl-microchip-sgpio.c b/drivers/pinctrl/pinctrl-microchip-sgpio.c index 6191e5c13815..069cc665a402 100644 --- a/drivers/pinctrl/pinctrl-microchip-sgpio.c +++ b/drivers/pinctrl/pinctrl-microchip-sgpio.c @@ -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;