Преглед изворни кода

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>
Frederic Barrat пре 7 година
родитељ
комит
423688abd9
1 измењених фајлова са 4 додато и 2 уклоњено
  1. 4 2
      drivers/misc/ocxl/file.c

+ 4 - 2
drivers/misc/ocxl/file.c

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