Skip to content

Commit 3b6f4bd

Browse files
qianfengrongbroonie
authored andcommitted
ASoC: fsl: Use kcalloc() instead of kzalloc()
Use devm_kcalloc() in fsl_sai_read_dlcfg() and imx_audmux_probe() 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://patch.msgid.link/20250820123423.470486-3-rongqianfeng@vivo.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 45441b9 commit 3b6f4bd

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

sound/soc/fsl/fsl_sai.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1345,7 +1345,7 @@ static int fsl_sai_read_dlcfg(struct fsl_sai *sai)
13451345

13461346
num_cfg = elems / 3;
13471347
/* Add one more for default value */
1348-
cfg = devm_kzalloc(&pdev->dev, (num_cfg + 1) * sizeof(*cfg), GFP_KERNEL);
1348+
cfg = devm_kcalloc(&pdev->dev, num_cfg + 1, sizeof(*cfg), GFP_KERNEL);
13491349
if (!cfg)
13501350
return -ENOMEM;
13511351

sound/soc/fsl/imx-audmux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ static int imx_audmux_probe(struct platform_device *pdev)
305305
return -EINVAL;
306306
}
307307

308-
regcache = devm_kzalloc(&pdev->dev, sizeof(u32) * reg_max, GFP_KERNEL);
308+
regcache = devm_kcalloc(&pdev->dev, reg_max, sizeof(u32), GFP_KERNEL);
309309
if (!regcache)
310310
return -ENOMEM;
311311

0 commit comments

Comments
 (0)