mirror of
https://github.com/torvalds/linux.git
synced 2026-05-27 08:33:17 +02:00
ASoC: Use kcalloc() instead of kzalloc()
Merge series from Qianfeng Rong <rongqianfeng@vivo.com>: Replace devm_kzalloc() with devm_kcalloc() in sound/soc. As noted in the kernel documentation [1], open-coded multiplication in allocator arguments is discouraged because it can lead to integer overflow. Using devm_kcalloc() provides built-in overflow protection, making the memory allocation safer when calculating the allocation size compared to explicit multiplication. [1]: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments
This commit is contained in:
commit
865052d16a
|
|
@ -111,7 +111,7 @@ static int fs_parse_scene_tables(struct fs_amp_lib *amp_lib)
|
|||
if (count <= 0)
|
||||
return -EFAULT;
|
||||
|
||||
scene = devm_kzalloc(amp_lib->dev, count * sizeof(*scene), GFP_KERNEL);
|
||||
scene = devm_kcalloc(amp_lib->dev, count, sizeof(*scene), GFP_KERNEL);
|
||||
if (!scene)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
|||
|
|
@ -1353,8 +1353,8 @@ static int pcmdev_gain_ctrl_add(struct pcmdevice_priv *pcm_dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
pcmdev_controls = devm_kzalloc(pcm_dev->dev,
|
||||
nr_chn * sizeof(struct snd_kcontrol_new), GFP_KERNEL);
|
||||
pcmdev_controls = devm_kcalloc(pcm_dev->dev, nr_chn,
|
||||
sizeof(struct snd_kcontrol_new), GFP_KERNEL);
|
||||
if (!pcmdev_controls)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
|||
|
|
@ -1345,7 +1345,7 @@ static int fsl_sai_read_dlcfg(struct fsl_sai *sai)
|
|||
|
||||
num_cfg = elems / 3;
|
||||
/* Add one more for default value */
|
||||
cfg = devm_kzalloc(&pdev->dev, (num_cfg + 1) * sizeof(*cfg), GFP_KERNEL);
|
||||
cfg = devm_kcalloc(&pdev->dev, num_cfg + 1, sizeof(*cfg), GFP_KERNEL);
|
||||
if (!cfg)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ static int imx_audmux_probe(struct platform_device *pdev)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
regcache = devm_kzalloc(&pdev->dev, sizeof(u32) * reg_max, GFP_KERNEL);
|
||||
regcache = devm_kcalloc(&pdev->dev, reg_max, sizeof(u32), GFP_KERNEL);
|
||||
if (!regcache)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
|||
|
|
@ -547,8 +547,8 @@ static int test_driver_probe(struct platform_device *pdev)
|
|||
|
||||
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
|
||||
cdriv = devm_kzalloc(dev, sizeof(*cdriv), GFP_KERNEL);
|
||||
ddriv = devm_kzalloc(dev, sizeof(*ddriv) * num, GFP_KERNEL);
|
||||
dname = devm_kzalloc(dev, sizeof(*dname) * num, GFP_KERNEL);
|
||||
ddriv = devm_kcalloc(dev, num, sizeof(*ddriv), GFP_KERNEL);
|
||||
dname = devm_kcalloc(dev, num, sizeof(*dname), GFP_KERNEL);
|
||||
if (!priv || !cdriv || !ddriv || !dname || !adata)
|
||||
return -EINVAL;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user