Skip to content

Commit

Permalink
blk_rq_map_user_iov: fix error override
Browse files Browse the repository at this point in the history
commit 69e0927 upstream.

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>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
doug-gilbert authored and gregkh committed Feb 25, 2018
1 parent 3ee287d commit 7abb5e9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions block/blk-map.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,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;
Expand Down Expand Up @@ -145,7 +145,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);

Expand Down

0 comments on commit 7abb5e9

Please sign in to comment.