Commit 85385c15 authored by Li Zefan's avatar Li Zefan Committed by Takashi Iwai

ALSA: sound/usb: 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 68425adc
...@@ -349,14 +349,10 @@ static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, ...@@ -349,14 +349,10 @@ static int usb_stream_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
if (cmd != SNDRV_USB_STREAM_IOCTL_SET_PARAMS) if (cmd != SNDRV_USB_STREAM_IOCTL_SET_PARAMS)
return -ENOTTY; return -ENOTTY;
cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); cfg = memdup_user((void *)arg, sizeof(*cfg));
if (!cfg) if (IS_ERR(cfg))
return -ENOMEM; return PTR_ERR(cfg);
if (copy_from_user(cfg, (void *)arg, sizeof(*cfg))) {
err = -EFAULT;
goto free;
}
if (cfg->version != USB_STREAM_INTERFACE_VERSION) { if (cfg->version != USB_STREAM_INTERFACE_VERSION) {
err = -ENXIO; err = -ENXIO;
goto free; goto free;
......
...@@ -203,13 +203,12 @@ static int snd_usX2Y_hwdep_dsp_load(struct snd_hwdep *hw, ...@@ -203,13 +203,12 @@ static int snd_usX2Y_hwdep_dsp_load(struct snd_hwdep *hw,
if (access_ok(VERIFY_READ, dsp->image, dsp->length)) { if (access_ok(VERIFY_READ, dsp->image, dsp->length)) {
struct usb_device* dev = priv->chip.dev; struct usb_device* dev = priv->chip.dev;
char *buf = kmalloc(dsp->length, GFP_KERNEL); char *buf;
if (!buf)
return -ENOMEM; buf = memdup_user(dsp->image, dsp->length);
if (copy_from_user(buf, dsp->image, dsp->length)) { if (IS_ERR(buf))
kfree(buf); return PTR_ERR(buf);
return -EFAULT;
}
err = usb_set_interface(dev, 0, 1); err = usb_set_interface(dev, 0, 1);
if (err) if (err)
snd_printk(KERN_ERR "usb_set_interface error \n"); snd_printk(KERN_ERR "usb_set_interface error \n");
......
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