From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752231AbbFZOKJ (ORCPT ); Fri, 26 Jun 2015 10:10:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41495 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751802AbbFZOKB (ORCPT ); Fri, 26 Jun 2015 10:10:01 -0400 From: Jeff Moyer To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, Jens Axboe Subject: Re: [PATCH] block: fix bogus EFAULT error from SG_IO ioctl References: <1435311886-30834-1-git-send-email-pbonzini@redhat.com> X-PGP-KeyID: 1F78E1B4 X-PGP-CertKey: F6FE 280D 8293 F72C 65FD 5A58 1FF8 A7CA 1F78 E1B4 X-PCLoadLetter: What the f**k does that mean? Date: Fri, 26 Jun 2015 10:09:59 -0400 In-Reply-To: <1435311886-30834-1-git-send-email-pbonzini@redhat.com> (Paolo Bonzini's message of "Fri, 26 Jun 2015 11:44:46 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Paolo Bonzini 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 Acked-by: Jeff Moyer > --- > 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;