Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
[cascardo/linux.git] / lib / dynamic_debug.c
index e3952e9..fe42b6e 100644 (file)
@@ -657,14 +657,9 @@ static ssize_t ddebug_proc_write(struct file *file, const char __user *ubuf,
                pr_warn("expected <%d bytes into control\n", USER_BUF_PAGE);
                return -E2BIG;
        }
-       tmpbuf = kmalloc(len + 1, GFP_KERNEL);
-       if (!tmpbuf)
-               return -ENOMEM;
-       if (copy_from_user(tmpbuf, ubuf, len)) {
-               kfree(tmpbuf);
-               return -EFAULT;
-       }
-       tmpbuf[len] = '\0';
+       tmpbuf = memdup_user_nul(ubuf, len);
+       if (IS_ERR(tmpbuf))
+               return PTR_ERR(tmpbuf);
        vpr_info("read %d bytes from userspace\n", (int)len);
 
        ret = ddebug_exec_queries(tmpbuf, NULL);