* [PATCH v1] ALSA: usb-audio: Use kmemdup_array instead of kmemdup for multiple allocation
@ 2024-08-26 4:34 Shen Lichuan
2024-08-26 8:32 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Shen Lichuan @ 2024-08-26 4:34 UTC (permalink / raw)
To: perex, tiwai; +Cc: linux-sound, linux-kernel, Shen Lichuan
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>
---
sound/usb/quirks.c | 4 ++--
1 file 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;
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-08-26 8:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-26 4:34 [PATCH v1] ALSA: usb-audio: Use kmemdup_array instead of kmemdup for multiple allocation Shen Lichuan
2024-08-26 8:32 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox