Skip to content

Commit 45441b9

Browse files
qianfengrongbroonie
authored andcommitted
ASoC: codecs: Use kcalloc() instead of kzalloc()
Use devm_kcalloc() in fs_parse_scene_tables() and pcmdev_gain_ctrl_add() to gain built-in overflow protection, making memory allocation safer when calculating allocation size compared to explicit multiplication. Signed-off-by: Qianfeng Rong <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 132e098 commit 45441b9

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

sound/soc/codecs/fs-amp-lib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static int fs_parse_scene_tables(struct fs_amp_lib *amp_lib)
111111
if (count <= 0)
112112
return -EFAULT;
113113

114-
scene = devm_kzalloc(amp_lib->dev, count * sizeof(*scene), GFP_KERNEL);
114+
scene = devm_kcalloc(amp_lib->dev, count, sizeof(*scene), GFP_KERNEL);
115115
if (!scene)
116116
return -ENOMEM;
117117

sound/soc/codecs/pcm6240.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,8 +1353,8 @@ static int pcmdev_gain_ctrl_add(struct pcmdevice_priv *pcm_dev,
13531353
return 0;
13541354
}
13551355

1356-
pcmdev_controls = devm_kzalloc(pcm_dev->dev,
1357-
nr_chn * sizeof(struct snd_kcontrol_new), GFP_KERNEL);
1356+
pcmdev_controls = devm_kcalloc(pcm_dev->dev, nr_chn,
1357+
sizeof(struct snd_kcontrol_new), GFP_KERNEL);
13581358
if (!pcmdev_controls)
13591359
return -ENOMEM;
13601360

0 commit comments

Comments
 (0)