]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
parisc: perf: return -EFAULT on error
authorDan Carpenter <dan.carpenter@oracle.com>
Sat, 10 Dec 2016 09:06:25 +0000 (12:06 +0300)
committerHelge Deller <deller@gmx.de>
Mon, 12 Dec 2016 21:29:49 +0000 (22:29 +0100)
The copy_from_user() returns the number of bytes remaining to be copied
but we want to return -EFAULT if it's non-zero.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Helge Deller <deller@gmx.de>
arch/parisc/kernel/perf.c

index 518f4f5f1f43ec6b2dcaceb9b2f5c9536097d59f..6eabce62463bbbcf29031143c46d7b75c841b6fa 100644 (file)
@@ -301,7 +301,6 @@ static ssize_t perf_read(struct file *file, char __user *buf, size_t cnt, loff_t
 static ssize_t perf_write(struct file *file, const char __user *buf, size_t count, 
        loff_t *ppos)
 {
-       int err;
        size_t image_size;
        uint32_t image_type;
        uint32_t interface_type;
@@ -320,8 +319,8 @@ static ssize_t perf_write(struct file *file, const char __user *buf, size_t coun
        if (count != sizeof(uint32_t))
                return -EIO;
 
-       if ((err = copy_from_user(&image_type, buf, sizeof(uint32_t))) != 0) 
-               return err;
+       if (copy_from_user(&image_type, buf, sizeof(uint32_t)))
+               return -EFAULT;
 
        /* Get the interface type and test type */
        interface_type = (image_type >> 16) & 0xffff;