Commit f7b1633d authored by Shen Lichuan's avatar Shen Lichuan Committed by Takashi Iwai

ALSA: usb-audio: Use kmemdup_array instead of kmemdup for multiple allocation

Let the kmemdup_array() take care about multiplication
and possible overflows.

Using kmemdup_array() is more appropriate and makes the code
easier to audit.
Signed-off-by: default avatarShen Lichuan <shenlichuan@vivo.com>
Link: https://patch.msgid.link/20240826043454.3198-1-shenlichuan@vivo.comSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent b29ba8f1
......@@ -167,8 +167,8 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip,
return -EINVAL;
}
if (fp->nr_rates > 0) {
rate_table = kmemdup(fp->rate_table,
sizeof(int) * fp->nr_rates, GFP_KERNEL);
rate_table = kmemdup_array(fp->rate_table, fp->nr_rates, sizeof(int),
GFP_KERNEL);
if (!rate_table) {
kfree(fp);
return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment