diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2009-04-09 21:43:08 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-04-14 06:39:12 -0400 |
commit | ef44a1ec6eeef189998f84e7230e1d3535b01074 (patch) | |
tree | 0baa5cc0bf27af13469c75bcb89cc55e448f45dd /sound/core/control.c | |
parent | 577c9c456f0e1371cbade38eaf91ae8e8a308555 (diff) |
ALSA: sound/core: use memdup_user()
Remove open-coded memdup_user().
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/control.c')
-rw-r--r-- | sound/core/control.c | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/sound/core/control.c b/sound/core/control.c index 4b20fa2b7e6d..17b8d47a5cd0 100644 --- a/sound/core/control.c +++ b/sound/core/control.c | |||
@@ -723,14 +723,11 @@ static int snd_ctl_elem_read_user(struct snd_card *card, | |||
723 | { | 723 | { |
724 | struct snd_ctl_elem_value *control; | 724 | struct snd_ctl_elem_value *control; |
725 | int result; | 725 | int result; |
726 | 726 | ||
727 | control = kmalloc(sizeof(*control), GFP_KERNEL); | 727 | control = memdup_user(_control, sizeof(*control)); |
728 | if (control == NULL) | 728 | if (IS_ERR(control)) |
729 | return -ENOMEM; | 729 | return PTR_ERR(control); |
730 | if (copy_from_user(control, _control, sizeof(*control))) { | 730 | |
731 | kfree(control); | ||
732 | return -EFAULT; | ||
733 | } | ||
734 | snd_power_lock(card); | 731 | snd_power_lock(card); |
735 | result = snd_power_wait(card, SNDRV_CTL_POWER_D0); | 732 | result = snd_power_wait(card, SNDRV_CTL_POWER_D0); |
736 | if (result >= 0) | 733 | if (result >= 0) |
@@ -784,13 +781,10 @@ static int snd_ctl_elem_write_user(struct snd_ctl_file *file, | |||
784 | struct snd_card *card; | 781 | struct snd_card *card; |
785 | int result; | 782 | int result; |
786 | 783 | ||
787 | control = kmalloc(sizeof(*control), GFP_KERNEL); | 784 | control = memdup_user(_control, sizeof(*control)); |
788 | if (control == NULL) | 785 | if (IS_ERR(control)) |
789 | return -ENOMEM; | 786 | return PTR_ERR(control); |
790 | if (copy_from_user(control, _control, sizeof(*control))) { | 787 | |
791 | kfree(control); | ||
792 | return -EFAULT; | ||
793 | } | ||
794 | card = file->card; | 788 | card = file->card; |
795 | snd_power_lock(card); | 789 | snd_power_lock(card); |
796 | result = snd_power_wait(card, SNDRV_CTL_POWER_D0); | 790 | result = snd_power_wait(card, SNDRV_CTL_POWER_D0); |
@@ -916,13 +910,10 @@ static int snd_ctl_elem_user_tlv(struct snd_kcontrol *kcontrol, | |||
916 | if (op_flag > 0) { | 910 | if (op_flag > 0) { |
917 | if (size > 1024 * 128) /* sane value */ | 911 | if (size > 1024 * 128) /* sane value */ |
918 | return -EINVAL; | 912 | return -EINVAL; |
919 | new_data = kmalloc(size, GFP_KERNEL); | 913 | |
920 | if (new_data == NULL) | 914 | new_data = memdup_user(tlv, size); |
921 | return -ENOMEM; | 915 | if (IS_ERR(new_data)) |
922 | if (copy_from_user(new_data, tlv, size)) { | 916 | return PTR_ERR(new_data); |
923 | kfree(new_data); | ||
924 | return -EFAULT; | ||
925 | } | ||
926 | change = ue->tlv_data_size != size; | 917 | change = ue->tlv_data_size != size; |
927 | if (!change) | 918 | if (!change) |
928 | change = memcmp(ue->tlv_data, new_data, size); | 919 | change = memcmp(ue->tlv_data, new_data, size); |