[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <54DB8406.4020804@cybernetics.com>
Date:	Wed, 11 Feb 2015 11:32:06 -0500
From:	Tony Battersby <tonyb@...ernetics.com>
To:	linux-scsi@...r.kernel.org,
	"James E.J. Bottomley" <JBottomley@...allels.com>,
	Douglas Gilbert <dgilbert@...erlog.com>
CC:	linux-kernel@...r.kernel.org
Subject: [PATCH] [SCSI] sg: fix read() error reporting
Fix SCSI generic read() incorrectly returning success after detecting an
error.
Cc: <stable@...r.kernel.org>
Signed-off-by: Tony Battersby <tonyb@...ernetics.com>
---
For inclusion in kernel 3.20.
--- linux-3.19.0/drivers/scsi/sg.c.orig	2015-02-08 21:54:22.000000000 -0500
+++ linux-3.19.0/drivers/scsi/sg.c	2015-02-10 09:26:09.000000000 -0500
@@ -546,7 +546,7 @@ static ssize_t
 sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, Sg_request * srp)
 {
 	sg_io_hdr_t *hp = &srp->header;
-	int err = 0;
+	int err = 0, err2;
 	int len;
 
 	if (count < SZ_SG_IO_HDR) {
@@ -575,8 +575,8 @@ sg_new_read(Sg_fd * sfp, char __user *bu
 		goto err_out;
 	}
 err_out:
-	err = sg_finish_rem_req(srp);
-	return (0 == err) ? count : err;
+	err2 = sg_finish_rem_req(srp);
+	return err ? : err2 ? : count;
 }
 
 static ssize_t
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Powered by blists - more mailing lists
 
