Commit 336500f0 authored by Li Zefan's avatar Li Zefan Committed by Takashi Iwai

ALSA: sound/pci: use memdup_user()

Remove open-coded memdup_user().
Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 85385c15
...@@ -2493,24 +2493,17 @@ static int snd_emu10k1_fx8010_ioctl(struct snd_hwdep * hw, struct file *file, un ...@@ -2493,24 +2493,17 @@ static int snd_emu10k1_fx8010_ioctl(struct snd_hwdep * hw, struct file *file, un
case SNDRV_EMU10K1_IOCTL_CODE_POKE: case SNDRV_EMU10K1_IOCTL_CODE_POKE:
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EPERM; return -EPERM;
icode = kmalloc(sizeof(*icode), GFP_KERNEL);
if (icode == NULL) icode = memdup_user(argp, sizeof(*icode));
return -ENOMEM; if (IS_ERR(icode))
if (copy_from_user(icode, argp, sizeof(*icode))) { return PTR_ERR(icode);
kfree(icode);
return -EFAULT;
}
res = snd_emu10k1_icode_poke(emu, icode); res = snd_emu10k1_icode_poke(emu, icode);
kfree(icode); kfree(icode);
return res; return res;
case SNDRV_EMU10K1_IOCTL_CODE_PEEK: case SNDRV_EMU10K1_IOCTL_CODE_PEEK:
icode = kmalloc(sizeof(*icode), GFP_KERNEL); icode = memdup_user(argp, sizeof(*icode));
if (icode == NULL) if (IS_ERR(icode))
return -ENOMEM; return PTR_ERR(icode);
if (copy_from_user(icode, argp, sizeof(*icode))) {
kfree(icode);
return -EFAULT;
}
res = snd_emu10k1_icode_peek(emu, icode); res = snd_emu10k1_icode_peek(emu, icode);
if (res == 0 && copy_to_user(argp, icode, sizeof(*icode))) { if (res == 0 && copy_to_user(argp, icode, sizeof(*icode))) {
kfree(icode); kfree(icode);
...@@ -2519,24 +2512,16 @@ static int snd_emu10k1_fx8010_ioctl(struct snd_hwdep * hw, struct file *file, un ...@@ -2519,24 +2512,16 @@ static int snd_emu10k1_fx8010_ioctl(struct snd_hwdep * hw, struct file *file, un
kfree(icode); kfree(icode);
return res; return res;
case SNDRV_EMU10K1_IOCTL_PCM_POKE: case SNDRV_EMU10K1_IOCTL_PCM_POKE:
ipcm = kmalloc(sizeof(*ipcm), GFP_KERNEL); ipcm = memdup_user(argp, sizeof(*ipcm));
if (ipcm == NULL) if (IS_ERR(ipcm))
return -ENOMEM; return PTR_ERR(ipcm);
if (copy_from_user(ipcm, argp, sizeof(*ipcm))) {
kfree(ipcm);
return -EFAULT;
}
res = snd_emu10k1_ipcm_poke(emu, ipcm); res = snd_emu10k1_ipcm_poke(emu, ipcm);
kfree(ipcm); kfree(ipcm);
return res; return res;
case SNDRV_EMU10K1_IOCTL_PCM_PEEK: case SNDRV_EMU10K1_IOCTL_PCM_PEEK:
ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL); ipcm = memdup_user(argp, sizeof(*ipcm));
if (ipcm == NULL) if (IS_ERR(ipcm))
return -ENOMEM; return PTR_ERR(ipcm);
if (copy_from_user(ipcm, argp, sizeof(*ipcm))) {
kfree(ipcm);
return -EFAULT;
}
res = snd_emu10k1_ipcm_peek(emu, ipcm); res = snd_emu10k1_ipcm_peek(emu, ipcm);
if (res == 0 && copy_to_user(argp, ipcm, sizeof(*ipcm))) { if (res == 0 && copy_to_user(argp, ipcm, sizeof(*ipcm))) {
kfree(ipcm); kfree(ipcm);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment