ocxl: Fix potential bad errno on irq allocation
authorFrederic Barrat <fbarrat@linux.vnet.ibm.com>
Fri, 16 Feb 2018 13:01:18 +0000 (14:01 +0100)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 21 Feb 2018 00:21:01 +0000 (11:21 +1100)
Fix some issues found by a static checker:

When allocating an AFU interrupt, if the driver cannot copy the output
parameters to userland, the errno value was not set to EFAULT

Remove a (now) useless cast.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
drivers/misc/ocxl/file.c

index 2dd2db9bc1c90f771ab19a4feabb167a6c367071..337462e1569fee2628fc6126c29c3acc9cc904ae 100644 (file)
@@ -133,8 +133,10 @@ static long afu_ioctl(struct file *file, unsigned int cmd,
                if (!rc) {
                        rc = copy_to_user((u64 __user *) args, &irq_offset,
                                        sizeof(irq_offset));
-                       if (rc)
+                       if (rc) {
                                ocxl_afu_irq_free(ctx, irq_offset);
+                               return -EFAULT;
+                       }
                }
                break;
 
@@ -329,7 +331,7 @@ static ssize_t afu_read(struct file *file, char __user *buf, size_t count,
 
        used += sizeof(header);
 
-       rc = (ssize_t) used;
+       rc = used;
        return rc;
 }