ocxl: Fix potential bad errno on irq allocation
Subsystems (2)
PATCH 1/1 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.
--- drivers/misc/ocxl/file.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/misc/ocxl/file.c +4 -2
@@ -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; }
Signature · 1 line
2.14.1
Quoted 9 lines · Frederic Barrat
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 <[email protected]>Signed-off-by Frederic Barrat <[email protected]>
Quoted 29 lines
--- drivers/misc/ocxl/file.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/misc/ocxl/file.c +4
-2@@ -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; }
Signature · 2 lines
Andrew Donnellan OzLabs, ADL Canberra [email protected] IBM Australia Limited
Michael Ellerman
AppliedQuoted 10 lines · Frederic Barrat
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 <[email protected]>Signed-off-by Frederic Barrat <[email protected]>Acked-by Andrew Donnellan <[email protected]>
Applied to powerpc fixes, thanks.
https://git.kernel.org/powerpc/c/423688abd9ab654044bddd82eb5983
cheers