]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
powerpc/pseries: use memdup_user_nul
authorGeliang Tang <geliangtang@gmail.com>
Sat, 29 Apr 2017 01:45:15 +0000 (09:45 +0800)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 24 Jul 2017 11:23:25 +0000 (21:23 +1000)
Use memdup_user_nul() helper instead of open-coding to simplify the code.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/platforms/pseries/reconfig.c

index e5bf1e84047f4c3fb9746ae85b0c6593f47ab012..431f513586a98e4fffd89ae644774b0f06d9328b 100644 (file)
@@ -367,16 +367,9 @@ static ssize_t ofdt_write(struct file *file, const char __user *buf, size_t coun
        char *kbuf;
        char *tmp;
 
-       if (!(kbuf = kmalloc(count + 1, GFP_KERNEL))) {
-               rv = -ENOMEM;
-               goto out;
-       }
-       if (copy_from_user(kbuf, buf, count)) {
-               rv = -EFAULT;
-               goto out;
-       }
-
-       kbuf[count] = '\0';
+       kbuf = memdup_user_nul(buf, count);
+       if (IS_ERR(kbuf))
+               return PTR_ERR(kbuf);
 
        tmp = strchr(kbuf, ' ');
        if (!tmp) {