ALSA: sound/isa: use memdup_user()
authorLi Zefan <lizf@cn.fujitsu.com>
Fri, 10 Apr 2009 01:43:36 +0000 (09:43 +0800)
committerTakashi Iwai <tiwai@suse.de>
Tue, 14 Apr 2009 10:39:23 +0000 (12:39 +0200)
Remove open-coded memdup_user().

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/isa/sb/sb16_csp.c
sound/isa/wavefront/wavefront_fx.c
sound/isa/wavefront/wavefront_synth.c

index 49037d074c719f8e2ef2160b1d8730af1dec2cf6..bdc8dde4e4a219ab09736a1f9455207f63dfa3c1 100644 (file)
@@ -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)
 {
-       int err = -ENOMEM;
-       unsigned char *kbuf = kmalloc(size, GFP_KERNEL);
-       if (kbuf) {
-               if (copy_from_user(kbuf, buf, size))
-                       err = -EFAULT;
-               else
-                       err = snd_sb_csp_load(p, kbuf, size, load_flags);
-               kfree(kbuf);
-       }
+       int err;
+       unsigned char *kbuf;
+
+       kbuf = memdup_user(buf, size);
+       if (IS_ERR(kbuf))
+               return PTR_ERR(kbuf);
+
+       err = snd_sb_csp_load(p, kbuf, size, load_flags);
+
+       kfree(kbuf);
        return err;
 }
 
index dfc449a2194e9795cb07cec10edf84af66b529ac..5e6870baa296ad206afaa4cdd084e317751f05c2 100644 (file)
@@ -210,15 +210,11 @@ snd_wavefront_fx_ioctl (struct snd_hwdep *sdev, struct file *file,
                                            "> 512 bytes to FX\n");
                                return -EIO;
                        }
-                       page_data = kmalloc(r.data[2] * sizeof(short), GFP_KERNEL);
-                       if (!page_data)
-                               return -ENOMEM;
-                       if (copy_from_user (page_data,
-                                           (unsigned char __user *) r.data[3],
-                                           r.data[2] * sizeof(short))) {
-                               kfree(page_data);
-                               return -EFAULT;
-                       }
+                       page_data = memdup_user((unsigned char __user *)
+                                               r.data[3],
+                                               r.data[2] * sizeof(short));
+                       if (IS_ERR(page_data))
+                               return PTR_ERR(page_data);
                        pd = page_data;
                }
 
index beb312cca75b7bbea9598073eb2128010a346fe2..5d4ff48c4345418a4a2fb4fe4d8f782472484143 100644 (file)
@@ -1664,12 +1664,11 @@ snd_wavefront_synth_ioctl (struct snd_hwdep *hw, struct file *file,
                break;
 
        case WFCTL_WFCMD:
-               wc = kmalloc(sizeof(*wc), GFP_KERNEL);
-               if (! wc)
-                       return -ENOMEM;
-               if (copy_from_user (wc, argp, sizeof (*wc)))
-                       err = -EFAULT;
-               else if (wavefront_synth_control (acard, wc) < 0)
+               wc = memdup_user(argp, sizeof(*wc));
+               if (IS_ERR(wc))
+                       return PTR_ERR(wc);
+
+               if (wavefront_synth_control (acard, wc) < 0)
                        err = -EIO;
                else if (copy_to_user (argp, wc, sizeof (*wc)))
                        err = -EFAULT;