Skip to content

Commit f4ace70

Browse files
pedrodemargomestiwai
authored andcommitted
ALSA: usb: fpc: replace kmalloc_array followed by copy_from_user with memdup_array_user
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 <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent 7ddb711 commit f4ace70

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

sound/usb/fcp.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -641,12 +641,9 @@ static int fcp_ioctl_set_meter_map(struct usb_mixer_interface *mixer,
641641
return -EINVAL;
642642

643643
/* Allocate and copy the map data */
644-
tmp_map = kmalloc_array(map.map_size, sizeof(s16), GFP_KERNEL);
645-
if (!tmp_map)
646-
return -ENOMEM;
647-
648-
if (copy_from_user(tmp_map, arg->map, map.map_size * sizeof(s16)))
649-
return -EFAULT;
644+
tmp_map = memdup_array_user(arg->map, map.map_size, sizeof(s16));
645+
if (IS_ERR(tmp_map))
646+
return PTR_ERR(tmp_map);
650647

651648
err = validate_meter_map(tmp_map, map.map_size, map.meter_slots);
652649
if (err < 0)

0 commit comments

Comments
 (0)