diff mbox

bsg: fix bogus EINVAL on non-data commands

Message ID 7730dcb2-7e69-3fc5-7eeb-4bbcf5091f14@cybernetics.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tony Battersby July 10, 2018, 4:52 p.m. UTC
Fix a regression introduced in Linux kernel 4.17 where sending a SCSI
command that does not transfer data (such as TEST UNIT READY) via
/dev/bsg/* results in EINVAL.

Fixes: 17cb960f29c2 ("bsg: split handling of SCSI CDBs vs transport requeues")
Cc: <stable@vger.kernel.org> # 4.17+
Signed-off-by: Tony Battersby <tonyb@cybernetics.com>
---

Comments

Christoph Hellwig July 11, 2018, 6:37 a.m. UTC | #1
On Tue, Jul 10, 2018 at 12:52:24PM -0400, Tony Battersby wrote:
> Fix a regression introduced in Linux kernel 4.17 where sending a SCSI
> command that does not transfer data (such as TEST UNIT READY) via
> /dev/bsg/* results in EINVAL.
> 
> Fixes: 17cb960f29c2 ("bsg: split handling of SCSI CDBs vs transport requeues")
> Cc: <stable@vger.kernel.org> # 4.17+
> Signed-off-by: Tony Battersby <tonyb@cybernetics.com>
> ---
> diff --git a/block/bsg.c b/block/bsg.c
> index 66602c4..b16ab6f 100644
> --- a/block/bsg.c
> +++ b/block/bsg.c
> @@ -268,7 +268,7 @@ bsg_map_hdr(struct request_queue *q, str
>  		ret = blk_rq_map_user(q, rq, NULL, uptr64(hdr->din_xferp),
>  				hdr->din_xfer_len, GFP_KERNEL);
>  	} else {
> -		ret = blk_rq_map_user(q, rq, NULL, NULL, 0, GFP_KERNEL);
> +		ret = 0;
>  	}

We can remove the else branch entirely as ret already is 0 here.

Otherwise this looks fine and restores the previous behavior:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Jens Axboe July 11, 2018, 2:48 p.m. UTC | #2
On 7/11/18 8:46 AM, Tony Battersby wrote:
> Fix a regression introduced in Linux kernel 4.17 where sending a SCSI
> command that does not transfer data (such as TEST UNIT READY) via
> /dev/bsg/* results in EINVAL.

Thanks Tony, applied for 4.18.
diff mbox

Patch

diff --git a/block/bsg.c b/block/bsg.c
index 66602c4..b16ab6f 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -268,7 +268,7 @@  bsg_map_hdr(struct request_queue *q, str
 		ret = blk_rq_map_user(q, rq, NULL, uptr64(hdr->din_xferp),
 				hdr->din_xfer_len, GFP_KERNEL);
 	} else {
-		ret = blk_rq_map_user(q, rq, NULL, NULL, 0, GFP_KERNEL);
+		ret = 0;
 	}
 
 	if (ret)