summaryrefslogtreecommitdiffstats
path: root/fs/block_dev.c
diff options
context:
space:
mode:
authorMartin Wilck <mwilck@suse.com>2018-07-25 23:15:08 +0200
committerJens Axboe <axboe@kernel.dk>2018-07-26 11:52:33 -0600
commit9362dd1109f87a9d0a798fbc890cb339c171ed35 (patch)
tree1cbf83057e024072940a67290c1f15ecc64e8bc4 /fs/block_dev.c
parentb403ea2404889e1227812fa9657667a1deb9c694 (diff)
downloadlinux-9362dd1109f87a9d0a798fbc890cb339c171ed35.tar.bz2
blkdev: __blkdev_direct_IO_simple: fix leak in error case
Fixes: 72ecad22d9f1 ("block: support a full bio worth of IO for simplified bdev direct-io") Reviewed-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Martin Wilck <mwilck@suse.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/block_dev.c')
-rw-r--r--fs/block_dev.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 05e12aea2404..192005376884 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -220,7 +220,7 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
ret = bio_iov_iter_get_pages(&bio, iter);
if (unlikely(ret))
- return ret;
+ goto out;
ret = bio.bi_iter.bi_size;
if (iov_iter_rw(iter) == READ) {
@@ -249,12 +249,13 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
put_page(bvec->bv_page);
}
- if (vecs != inline_vecs)
- kfree(vecs);
-
if (unlikely(bio.bi_status))
ret = blk_status_to_errno(bio.bi_status);
+out:
+ if (vecs != inline_vecs)
+ kfree(vecs);
+
bio_uninit(&bio);
return ret;