]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
pinctrl: microchip-sgpio: use kcalloc() instead of kzalloc()
authorQianfeng Rong <rongqianfeng@vivo.com>
Tue, 19 Aug 2025 14:39:32 +0000 (22:39 +0800)
committerLinus Walleij <linus.walleij@linaro.org>
Thu, 21 Aug 2025 11:28:49 +0000 (13:28 +0200)
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>
drivers/pinctrl/pinctrl-microchip-sgpio.c

index 6191e5c13815310b8ecf65ae3d3c0a1caaf775ee..069cc665a4023a67b40b94b68dec8dde37776755 100644 (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;