Skip to content

Commit

Permalink
ALSA: sound/usb: use memdup_user()
Browse files Browse the repository at this point in the history
Remove open-coded memdup_user().

Signed-off-by: Li Zefan <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
Li Zefan authored and tiwai committed Apr 14, 2009
1 parent 68425ad commit 85385c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
10 changes: 3 additions & 7 deletions sound/usb/usx2y/us122l.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
return -ENOTTY;

cfg = kmalloc(sizeof(*cfg), GFP_KERNEL);
if (!cfg)
return -ENOMEM;
cfg = memdup_user((void *)arg, sizeof(*cfg));
if (IS_ERR(cfg))
return PTR_ERR(cfg);

if (copy_from_user(cfg, (void *)arg, sizeof(*cfg))) {
err = -EFAULT;
goto free;
}
if (cfg->version != USB_STREAM_INTERFACE_VERSION) {
err = -ENXIO;
goto free;
Expand Down
13 changes: 6 additions & 7 deletions sound/usb/usx2y/usX2Yhwdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,12 @@ static int snd_usX2Y_hwdep_dsp_load(struct snd_hwdep *hw,

if (access_ok(VERIFY_READ, dsp->image, dsp->length)) {
struct usb_device* dev = priv->chip.dev;
char *buf = kmalloc(dsp->length, GFP_KERNEL);
if (!buf)
return -ENOMEM;
if (copy_from_user(buf, dsp->image, dsp->length)) {
kfree(buf);
return -EFAULT;
}
char *buf;

buf = memdup_user(dsp->image, dsp->length);
if (IS_ERR(buf))
return PTR_ERR(buf);

err = usb_set_interface(dev, 0, 1);
if (err)
snd_printk(KERN_ERR "usb_set_interface error \n");
Expand Down

0 comments on commit 85385c1

Please sign in to comment.