From: Paolo Bonzini Date: Fri, 26 Jun 2015 09:44:46 +0000 (+0200) Subject: block: fix bogus EFAULT error from SG_IO ioctl X-Git-Tag: submit/tizen/20160607.132125~2208^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2c4cffe85170a001c1d092681c86aa1128295221;p=sdk%2Femulator%2Femulator-kernel.git block: fix bogus EFAULT error from SG_IO ioctl 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 Acked-by: Jeff Moyer Signed-off-by: Jens Axboe --- diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c index 55b6f15..dda653c 100644 --- a/block/scsi_ioctl.c +++ b/block/scsi_ioctl.c @@ -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;