[PATCH] ocxl: Fix potential bad errno on irq allocation

Subsystems: char and misc drivers, ocxl (open coherent accelerator processor interface opencapi) driver, the rest

STALE3092d

3 messages, 3 authors, 2018-02-21 · open the first message on its own page

[PATCH] ocxl: Fix potential bad errno on irq allocation

From: Frederic Barrat <hidden>
Date: 2018-02-16 13:01:28

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 <redacted>
Signed-off-by: Frederic Barrat <redacted>
---
 drivers/misc/ocxl/file.c | 6 ++++--
 1 file 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,
 		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;
 }
 
-- 
2.14.1

Re: [PATCH] ocxl: Fix potential bad errno on irq allocation

From: Andrew Donnellan <hidden>
Date: 2018-02-20 23:21:33

On 17/02/18 00:01, Frederic Barrat wrote:
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 <redacted>
Signed-off-by: Frederic Barrat <redacted>
Acked-by: Andrew Donnellan <redacted>
quoted hunk
---
  drivers/misc/ocxl/file.c | 6 ++++--
  1 file 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,
  		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;
  }
-- 
Andrew Donnellan              OzLabs, ADL Canberra
andrew.donnellan@au1.ibm.com  IBM Australia Limited

Re: ocxl: Fix potential bad errno on irq allocation

From: Michael Ellerman <hidden>
Date: 2018-02-21 13:43:08

On Fri, 2018-02-16 at 13:01:18 UTC, Frederic Barrat wrote:
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 <redacted>
Signed-off-by: Frederic Barrat <redacted>
Acked-by: Andrew Donnellan <redacted>
Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/423688abd9ab654044bddd82eb5983

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help