[PATCH] spi: SPISG: Use devm_kcalloc() in aml_spisg_clk_init()

Qianfeng Rong posted 1 patch 1 month, 2 weeks ago
drivers/spi/spi-amlogic-spisg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] spi: SPISG: Use devm_kcalloc() in aml_spisg_clk_init()
Posted by Qianfeng Rong 1 month, 2 weeks ago
Replace calls of devm_kzalloc() with devm_kcalloc() in aml_spisg_clk_init()
for safer memory allocation with built-in overflow protection, and replace
sizeof(struct clk_div_table) with sizeof(*tbl) to shorten the line.

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
 drivers/spi/spi-amlogic-spisg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-amlogic-spisg.c b/drivers/spi/spi-amlogic-spisg.c
index 2ab8bdf2a676..64244a0bd408 100644
--- a/drivers/spi/spi-amlogic-spisg.c
+++ b/drivers/spi/spi-amlogic-spisg.c
@@ -662,7 +662,7 @@ static int aml_spisg_clk_init(struct spisg_device *spisg, void __iomem *base)
 
 	clk_disable_unprepare(spisg->pclk);
 
-	tbl = devm_kzalloc(dev, sizeof(struct clk_div_table) * (DIV_NUM + 1), GFP_KERNEL);
+	tbl = devm_kcalloc(dev, (DIV_NUM + 1), sizeof(*tbl), GFP_KERNEL);
 	if (!tbl)
 		return -ENOMEM;
 
-- 
2.34.1
Re: [PATCH] spi: SPISG: Use devm_kcalloc() in aml_spisg_clk_init()
Posted by Mark Brown 1 month, 2 weeks ago
On Tue, 19 Aug 2025 12:02:38 +0800, Qianfeng Rong wrote:
> Replace calls of devm_kzalloc() with devm_kcalloc() in aml_spisg_clk_init()
> for safer memory allocation with built-in overflow protection, and replace
> sizeof(struct clk_div_table) with sizeof(*tbl) to shorten the line.
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: SPISG: Use devm_kcalloc() in aml_spisg_clk_init()
      commit: c1dd310f1d76b4b13f1854618087af2513140897

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark