mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-22 17:01:14 +00:00
ALSA: sound/isa: 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:
parent
ef44a1ec6e
commit
68425adcc4
3 changed files with 20 additions and 24 deletions
|
@ -684,15 +684,16 @@ static int snd_sb_csp_load(struct snd_sb_csp * p, const unsigned char *buf, int
|
||||||
|
|
||||||
static int snd_sb_csp_load_user(struct snd_sb_csp * p, const unsigned char __user *buf, int size, int load_flags)
|
static int snd_sb_csp_load_user(struct snd_sb_csp * p, const unsigned char __user *buf, int size, int load_flags)
|
||||||
{
|
{
|
||||||
int err = -ENOMEM;
|
int err;
|
||||||
unsigned char *kbuf = kmalloc(size, GFP_KERNEL);
|
unsigned char *kbuf;
|
||||||
if (kbuf) {
|
|
||||||
if (copy_from_user(kbuf, buf, size))
|
kbuf = memdup_user(buf, size);
|
||||||
err = -EFAULT;
|
if (IS_ERR(kbuf))
|
||||||
else
|
return PTR_ERR(kbuf);
|
||||||
err = snd_sb_csp_load(p, kbuf, size, load_flags);
|
|
||||||
kfree(kbuf);
|
err = snd_sb_csp_load(p, kbuf, size, load_flags);
|
||||||
}
|
|
||||||
|
kfree(kbuf);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -210,15 +210,11 @@ snd_wavefront_fx_ioctl (struct snd_hwdep *sdev, struct file *file,
|
||||||
"> 512 bytes to FX\n");
|
"> 512 bytes to FX\n");
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
page_data = kmalloc(r.data[2] * sizeof(short), GFP_KERNEL);
|
page_data = memdup_user((unsigned char __user *)
|
||||||
if (!page_data)
|
r.data[3],
|
||||||
return -ENOMEM;
|
r.data[2] * sizeof(short));
|
||||||
if (copy_from_user (page_data,
|
if (IS_ERR(page_data))
|
||||||
(unsigned char __user *) r.data[3],
|
return PTR_ERR(page_data);
|
||||||
r.data[2] * sizeof(short))) {
|
|
||||||
kfree(page_data);
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
pd = page_data;
|
pd = page_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1664,12 +1664,11 @@ snd_wavefront_synth_ioctl (struct snd_hwdep *hw, struct file *file,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WFCTL_WFCMD:
|
case WFCTL_WFCMD:
|
||||||
wc = kmalloc(sizeof(*wc), GFP_KERNEL);
|
wc = memdup_user(argp, sizeof(*wc));
|
||||||
if (! wc)
|
if (IS_ERR(wc))
|
||||||
return -ENOMEM;
|
return PTR_ERR(wc);
|
||||||
if (copy_from_user (wc, argp, sizeof (*wc)))
|
|
||||||
err = -EFAULT;
|
if (wavefront_synth_control (acard, wc) < 0)
|
||||||
else if (wavefront_synth_control (acard, wc) < 0)
|
|
||||||
err = -EIO;
|
err = -EIO;
|
||||||
else if (copy_to_user (argp, wc, sizeof (*wc)))
|
else if (copy_to_user (argp, wc, sizeof (*wc)))
|
||||||
err = -EFAULT;
|
err = -EFAULT;
|
||||||
|
|
Loading…
Reference in a new issue