Skip to contentSkip to conversation

rsxx: Correcting return values during failure scenarios.

PATCH New Philip J. Kelleher 1 participant 1 message Aug 6, 2013 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 3/4 rsxx: Correcting return values during failure scenarios.

From: Philip J Kelleher <[email protected]>

The rsxx driver is returning the wrong values during copy_from_user and copy_to_user. It, also, is not setting ENOMEM during a failed workqueue allocation.

-------------------------------------------------------------------------------

drivers/block/rsxx/core.c +5 -6
diff -uprN -X linux-block-vanilla/Documentation/dontdiff linux-block-vanilla/drivers/block/rsxx/core.c linux-block/drivers/block/rsxx/core.c
@@ -199,9 +199,8 @@ static ssize_t rsxx_cram_read(struct fil
 	if (st)
 		return st;
 
-	st = copy_to_user(ubuf, buf, cnt);
-	if (st)
-		return st;
+	if (copy_to_user(ubuf, buf, cnt))
+		return -EFAULT;
 
 	info->offset += cnt;
 
@@ -222,9 +221,8 @@ static ssize_t rsxx_cram_write(struct fi
 	if (!buf)
 		return -ENOMEM;
 
-	st = copy_from_user(buf, ubuf, cnt);
-	if (st)
-		return st;
+	if (copy_from_user(buf, ubuf, cnt))
+		return -EFAULT;
 
 	info->f_pos = (u32)*ppos + info->offset;
 
@@ -946,6 +944,7 @@ static int rsxx_pci_probe(struct pci_dev
 	card->event_wq = create_singlethread_workqueue(DRIVER_NAME"_event");
 	if (!card->event_wq) {
 		dev_err(CARD_TO_DEV(card), "Failed card event setup.\n");
+		st = -ENOMEM;
 		goto failed_event_handler;
 	}