* [PATCH] ALSA: usb: fpc: replace kmalloc_array followed by copy_from_user with memdup_array_user
@ 2025-10-07 12:00 Pedro Demarchi Gomes
2025-10-07 12:14 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Pedro Demarchi Gomes @ 2025-10-07 12:00 UTC (permalink / raw)
To: Geoffrey D . Bennett, Jaroslav Kysela, Takashi Iwai
Cc: linux-sound, linux-kernel, Pedro Demarchi Gomes
Replace kmalloc_array() followed by copy_from_user() with
memdup_array_user() to improve and simplify fcp_ioctl_set_meter_map().
No functional changes intended.
Signed-off-by: Pedro Demarchi Gomes <pedrodemargomes@gmail.com>
---
sound/usb/fcp.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/sound/usb/fcp.c b/sound/usb/fcp.c
index 5ee8d8b66058..11e9a96b46ff 100644
--- a/sound/usb/fcp.c
+++ b/sound/usb/fcp.c
@@ -641,12 +641,9 @@ static int fcp_ioctl_set_meter_map(struct usb_mixer_interface *mixer,
return -EINVAL;
/* Allocate and copy the map data */
- tmp_map = kmalloc_array(map.map_size, sizeof(s16), GFP_KERNEL);
- if (!tmp_map)
- return -ENOMEM;
-
- if (copy_from_user(tmp_map, arg->map, map.map_size * sizeof(s16)))
- return -EFAULT;
+ tmp_map = memdup_array_user(arg->map, map.map_size, sizeof(s16));
+ if (IS_ERR(tmp_map))
+ return PTR_ERR(tmp_map);
err = validate_meter_map(tmp_map, map.map_size, map.meter_slots);
if (err < 0)
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ALSA: usb: fpc: replace kmalloc_array followed by copy_from_user with memdup_array_user
2025-10-07 12:00 [PATCH] ALSA: usb: fpc: replace kmalloc_array followed by copy_from_user with memdup_array_user Pedro Demarchi Gomes
@ 2025-10-07 12:14 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2025-10-07 12:14 UTC (permalink / raw)
To: Pedro Demarchi Gomes
Cc: Geoffrey D . Bennett, Jaroslav Kysela, Takashi Iwai, linux-sound,
linux-kernel
On Tue, 07 Oct 2025 14:00:57 +0200,
Pedro Demarchi Gomes wrote:
>
> Replace kmalloc_array() followed by copy_from_user() with
> memdup_array_user() to improve and simplify fcp_ioctl_set_meter_map().
>
> No functional changes intended.
>
> Signed-off-by: Pedro Demarchi Gomes <pedrodemargomes@gmail.com>
Applied now. Thanks.
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-10-07 12:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-07 12:00 [PATCH] ALSA: usb: fpc: replace kmalloc_array followed by copy_from_user with memdup_array_user Pedro Demarchi Gomes
2025-10-07 12:14 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox