Skip to content

Commit

Permalink
sg: fix read() error reporting
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Tony Battersby authored and James Bottomley committed Feb 15, 2015
1 parent 2ecf8e0 commit 3b524a6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/scsi/sg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3b524a6

Please sign in to comment.