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>
This commit is contained in:
@@ -723,14 +723,11 @@ static int snd_ctl_elem_read_user(struct snd_card *card,
|
||||
{
|
||||
struct snd_ctl_elem_value *control;
|
||||
int result;
|
||||
|
||||
control = kmalloc(sizeof(*control), GFP_KERNEL);
|
||||
if (control == NULL)
|
||||
return -ENOMEM;
|
||||
if (copy_from_user(control, _control, sizeof(*control))) {
|
||||
kfree(control);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
control = memdup_user(_control, sizeof(*control));
|
||||
if (IS_ERR(control))
|
||||
return PTR_ERR(control);
|
||||
|
||||
snd_power_lock(card);
|
||||
result = snd_power_wait(card, SNDRV_CTL_POWER_D0);
|
||||
if (result >= 0)
|
||||
@@ -784,13 +781,10 @@ static int snd_ctl_elem_write_user(struct snd_ctl_file *file,
|
||||
struct snd_card *card;
|
||||
int result;
|
||||
|
||||
control = kmalloc(sizeof(*control), GFP_KERNEL);
|
||||
if (control == NULL)
|
||||
return -ENOMEM;
|
||||
if (copy_from_user(control, _control, sizeof(*control))) {
|
||||
kfree(control);
|
||||
return -EFAULT;
|
||||
}
|
||||
control = memdup_user(_control, sizeof(*control));
|
||||
if (IS_ERR(control))
|
||||
return PTR_ERR(control);
|
||||
|
||||
card = file->card;
|
||||
snd_power_lock(card);
|
||||
result = snd_power_wait(card, SNDRV_CTL_POWER_D0);
|
||||
@@ -916,13 +910,10 @@ static int snd_ctl_elem_user_tlv(struct snd_kcontrol *kcontrol,
|
||||
if (op_flag > 0) {
|
||||
if (size > 1024 * 128) /* sane value */
|
||||
return -EINVAL;
|
||||
new_data = kmalloc(size, GFP_KERNEL);
|
||||
if (new_data == NULL)
|
||||
return -ENOMEM;
|
||||
if (copy_from_user(new_data, tlv, size)) {
|
||||
kfree(new_data);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
new_data = memdup_user(tlv, size);
|
||||
if (IS_ERR(new_data))
|
||||
return PTR_ERR(new_data);
|
||||
change = ue->tlv_data_size != size;
|
||||
if (!change)
|
||||
change = memcmp(ue->tlv_data, new_data, size);
|
||||
|
Reference in New Issue
Block a user