blk_rq_map_user_iov: fix error override
authorDouglas Gilbert <dgilbert@interlog.com>
Sun, 14 Jan 2018 22:00:48 +0000 (17:00 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 25 Feb 2018 10:07:49 +0000 (11:07 +0100)
commit 69e0927b3774563c19b5fb32e91d75edc147fb62 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>
block/blk-map.c

index 368daa02714e316c395273aad9775f3b9c3c630a..e31be14da8ea1a7e55277665943a8ae29b417716 100644 (file)
@@ -126,7 +126,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;
@@ -155,7 +155,7 @@ unmap_rq:
        __blk_rq_unmap_user(bio);
 fail:
        rq->bio = NULL;
-       return -EINVAL;
+       return ret;
 }
 EXPORT_SYMBOL(blk_rq_map_user_iov);