diff options
author | Frederic Barrat <fbarrat@linux.vnet.ibm.com> | 2018-02-16 08:01:18 -0500 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2018-02-20 19:21:01 -0500 |
commit | 423688abd9ab654044bddd82eb5983189eb9630d (patch) | |
tree | 02a48b03af86049be78b3ef41a7737a8ed1e3493 /drivers/misc/ocxl/file.c | |
parent | 521ca5a9859a870e354d1a6b84a6ff4c07bbceb0 (diff) |
ocxl: Fix potential bad errno on irq allocation
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>
Diffstat (limited to 'drivers/misc/ocxl/file.c')
-rw-r--r-- | drivers/misc/ocxl/file.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c index 2dd2db9bc1c9..337462e1569f 100644 --- a/drivers/misc/ocxl/file.c +++ b/drivers/misc/ocxl/file.c | |||
@@ -133,8 +133,10 @@ static long afu_ioctl(struct file *file, unsigned int cmd, | |||
133 | if (!rc) { | 133 | if (!rc) { |
134 | rc = copy_to_user((u64 __user *) args, &irq_offset, | 134 | rc = copy_to_user((u64 __user *) args, &irq_offset, |
135 | sizeof(irq_offset)); | 135 | sizeof(irq_offset)); |
136 | if (rc) | 136 | if (rc) { |
137 | ocxl_afu_irq_free(ctx, irq_offset); | 137 | ocxl_afu_irq_free(ctx, irq_offset); |
138 | return -EFAULT; | ||
139 | } | ||
138 | } | 140 | } |
139 | break; | 141 | break; |
140 | 142 | ||
@@ -329,7 +331,7 @@ static ssize_t afu_read(struct file *file, char __user *buf, size_t count, | |||
329 | 331 | ||
330 | used += sizeof(header); | 332 | used += sizeof(header); |
331 | 333 | ||
332 | rc = (ssize_t) used; | 334 | rc = used; |
333 | return rc; | 335 | return rc; |
334 | } | 336 | } |
335 | 337 | ||