]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
spi: SPISG: Use devm_kcalloc() in aml_spisg_clk_init()
authorQianfeng Rong <rongqianfeng@vivo.com>
Tue, 19 Aug 2025 04:02:38 +0000 (12:02 +0800)
committerMark Brown <broonie@kernel.org>
Tue, 19 Aug 2025 12:04:53 +0000 (13:04 +0100)
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>
Link: https://patch.msgid.link/20250819040239.434863-1-rongqianfeng@vivo.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-amlogic-spisg.c

index 2ab8bdf2a6761e90852355540f20c48423ad851c..64244a0bd40868b91a27169abe93ee0a85638151 100644 (file)
@@ -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;