Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <pedrodemargomes@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Pedro Demarchi Gomes and committed by
Takashi Iwai
f4ace70f 7ddb711b

+3 -6
+3 -6
sound/usb/fcp.c
··· 641 641 return -EINVAL; 642 642 643 643 /* 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); 650 647 651 648 err = validate_meter_map(tmp_map, map.map_size, map.meter_slots); 652 649 if (err < 0)