diff mbox

blk_rq_map_user_iov: fix error override

Message ID 20180114220048.8114-1-dgilbert@interlog.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Douglas Gilbert Jan. 14, 2018, 10 p.m. UTC
During stress tests by syzkaller on the sg driver the block layer
infrequently returns EINVAL. Closer inspection shows the block
layer was trying to return ENOMEM (which is much more
understandable) but for some reason overroad that useful error.

Patch below does not show this (unchanged) line:
   ret =__blk_rq_map_user_iov(rq, map_data, &i, gfp_mask, copy);
That 'ret' was being overridden when that function failed.

Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
---
 block/blk-map.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jens Axboe Jan. 15, 2018, 3:50 p.m. UTC | #1
On 1/14/18 3:00 PM, Douglas Gilbert wrote:
> During stress tests by syzkaller on the sg driver the block layer
> infrequently returns EINVAL. Closer inspection shows the block
> layer was trying to return ENOMEM (which is much more
> understandable) but for some reason overroad that useful error.
> 
> Patch below does not show this (unchanged) line:
>    ret =__blk_rq_map_user_iov(rq, map_data, &i, gfp_mask, copy);
> That 'ret' was being overridden when that function failed.

Thanks, applied.
diff mbox

Patch

diff --git a/block/blk-map.c b/block/blk-map.c
index d3a94719f03f..db9373bd31ac 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -119,7 +119,7 @@  int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
 	unsigned long align = q->dma_pad_mask | queue_dma_alignment(q);
 	struct bio *bio = NULL;
 	struct iov_iter i;
-	int ret;
+	int ret = -EINVAL;
 
 	if (!iter_is_iovec(iter))
 		goto fail;
@@ -148,7 +148,7 @@  int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
 	__blk_rq_unmap_user(bio);
 fail:
 	rq->bio = NULL;
-	return -EINVAL;
+	return ret;
 }
 EXPORT_SYMBOL(blk_rq_map_user_iov);