Skip to content

Commit

Permalink
block: fix bogus EFAULT error from SG_IO ioctl
Browse files Browse the repository at this point in the history
Whenever blk_fill_sghdr_rq fails, its errno code is ignored and changed to
EFAULT.  This can cause very confusing errors:

  $ sg_persist -k /dev/sda
  persistent reservation in: pass through os error: Bad address

The fix is trivial, just propagate the return value from
blk_fill_sghdr_rq.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
bonzini authored and axboe committed Jun 27, 2015
1 parent 3399a3f commit 2c4cffe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions block/scsi_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
goto out_put_request;
}

ret = -EFAULT;
if (blk_fill_sghdr_rq(q, rq, hdr, mode))
ret = blk_fill_sghdr_rq(q, rq, hdr, mode);
if (ret < 0)
goto out_free_cdb;

ret = 0;
Expand Down

0 comments on commit 2c4cffe

Please sign in to comment.