summaryrefslogtreecommitdiff
path: root/sound/usb
diff options
context:
space:
mode:
authorShen Lichuan <shenlichuan@vivo.com>2024-08-26 12:34:54 +0800
committerTakashi Iwai <tiwai@suse.de>2024-08-26 10:32:12 +0200
commitf7b1633d6467a08ff78744cb519a92fb24ad9a0c (patch)
treeb46260299b340d2e0731d4e159ab216874cfa640 /sound/usb
parentb29ba8f1f9429b775a8b901364a21291588c2a23 (diff)
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: Shen Lichuan <shenlichuan@vivo.com> Link: https://patch.msgid.link/20240826043454.3198-1-shenlichuan@vivo.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
-rw-r--r--sound/usb/quirks.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index e7b68c67852e..53c69f3069c4 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -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;