public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: fix bogus EFAULT error from SG_IO ioctl
@ 2015-06-26  9:44 Paolo Bonzini
  2015-06-26 14:09 ` Jeff Moyer
  2015-06-27 17:43 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: Paolo Bonzini @ 2015-06-26  9:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jens Axboe

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>
---
 block/scsi_ioctl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index 55b6f15dac90..dda653ce7b24 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;
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] block: fix bogus EFAULT error from SG_IO ioctl
  2015-06-26  9:44 [PATCH] block: fix bogus EFAULT error from SG_IO ioctl Paolo Bonzini
@ 2015-06-26 14:09 ` Jeff Moyer
  2015-06-27 17:43 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff Moyer @ 2015-06-26 14:09 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: linux-kernel, Jens Axboe

Paolo Bonzini <pbonzini@redhat.com> writes:

> 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>

> ---
>  block/scsi_ioctl.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
> index 55b6f15dac90..dda653ce7b24 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;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] block: fix bogus EFAULT error from SG_IO ioctl
  2015-06-26  9:44 [PATCH] block: fix bogus EFAULT error from SG_IO ioctl Paolo Bonzini
  2015-06-26 14:09 ` Jeff Moyer
@ 2015-06-27 17:43 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2015-06-27 17:43 UTC (permalink / raw)
  To: Paolo Bonzini, linux-kernel

On 06/26/2015 03:44 AM, Paolo Bonzini wrote:
> 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.

Added, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-06-27 17:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-26  9:44 [PATCH] block: fix bogus EFAULT error from SG_IO ioctl Paolo Bonzini
2015-06-26 14:09 ` Jeff Moyer
2015-06-27 17:43 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox