summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Battersby <tonyb@cybernetics.com>2015-02-11 11:32:06 -0500
committerLuis Henriques <luis.henriques@canonical.com>2015-03-02 15:04:27 +0000
commit2b8a5d91fc478ed5100a19d48dc3dbe79639d579 (patch)
treec7fbfac452cc1ee62bc92714cf093a0558d54b25
parent0a79bd3a2ac1216e0cb93ab6d28c52b3fe1860dc (diff)
downloadlinux-stable-2b8a5d91fc478ed5100a19d48dc3dbe79639d579.tar.gz
linux-stable-2b8a5d91fc478ed5100a19d48dc3dbe79639d579.tar.bz2
linux-stable-2b8a5d91fc478ed5100a19d48dc3dbe79639d579.zip
sg: fix read() error reporting
commit 3b524a683af8991b4eab4182b947c65f0ce1421b upstream. Fix SCSI generic read() incorrectly returning success after detecting an error. Signed-off-by: Tony Battersby <tonyb@cybernetics.com> Acked-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com> Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
-rw-r--r--drivers/scsi/sg.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 53268aaba559..791460b798f4 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -522,7 +522,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) {
@@ -551,8 +551,8 @@ sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, Sg_request * srp)
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