]> git.karo-electronics.de Git - linux-beck.git/commitdiff
sg: fix read() error reporting
authorTony Battersby <tonyb@cybernetics.com>
Wed, 11 Feb 2015 16:32:06 +0000 (11:32 -0500)
committerJames Bottomley <JBottomley@Parallels.com>
Sun, 15 Feb 2015 18:36:55 +0000 (10:36 -0800)
Fix SCSI generic read() incorrectly returning success after detecting an
error.

Cc: <stable@vger.kernel.org>
Signed-off-by: Tony Battersby <tonyb@cybernetics.com>
Acked-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
drivers/scsi/sg.c

index a668c88ea150f75a43281da4ed8168c9012dffd6..6ad1480e87b7288e1dad29848a945f1b09d13e37 100644 (file)
@@ -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 *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