[PATCH 0/4] pinctrl: use kcalloc() instead of kzalloc()

Qianfeng Rong posted 4 patches 1 month, 2 weeks ago
drivers/pinctrl/pinctrl-microchip-sgpio.c | 2 +-
drivers/pinctrl/pinctrl-zynqmp.c          | 2 +-
drivers/pinctrl/qcom/pinctrl-sc8180x.c    | 2 +-
drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c  | 4 ++--
4 files changed, 5 insertions(+), 5 deletions(-)
[PATCH 0/4] pinctrl: use kcalloc() instead of kzalloc()
Posted by Qianfeng Rong 1 month, 2 weeks ago
Replace devm_kzalloc() with devm_kcalloc() in drivers/pinctrl.  As noted
in the kernel documentation [1], open-coded multiplication in allocator
arguments is discouraged because it can lead to integer overflow.

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

[1]: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments

Qianfeng Rong (4):
  pinctrl: microchip-sgpio: use kcalloc() instead of kzalloc()
  pinctrl: pinctrl-zynqmp: use kcalloc() instead of kzalloc()
  pinctrl: qcom: sc8180x: use kcalloc() instead of kzalloc()
  pinctrl: sunxi: use kcalloc() instead of kzalloc()

 drivers/pinctrl/pinctrl-microchip-sgpio.c | 2 +-
 drivers/pinctrl/pinctrl-zynqmp.c          | 2 +-
 drivers/pinctrl/qcom/pinctrl-sc8180x.c    | 2 +-
 drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c  | 4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)

-- 
2.34.1
Re: [PATCH 0/4] pinctrl: use kcalloc() instead of kzalloc()
Posted by Linus Walleij 1 month, 1 week ago
On Tue, Aug 19, 2025 at 4:39 PM Qianfeng Rong <rongqianfeng@vivo.com> wrote:

> Replace devm_kzalloc() with devm_kcalloc() in drivers/pinctrl.  As noted
> in the kernel documentation [1], open-coded multiplication in allocator
> arguments is discouraged because it can lead to integer overflow.
>
> Use devm_kcalloc() to gain built-in overflow protection, making memory
> allocation safer when calculating allocation size compared to explicit
> multiplication.

All patches applied!

Yours,
Linus Walleij