blkdev: __blkdev_direct_IO_simple: fix leak in error case

commit 9362dd1109 upstream.

Fixes: 72ecad22d9 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Martin Wilck 2018-07-25 23:15:08 +02:00 коммит произвёл Greg Kroah-Hartman
Родитель 2258351cf0
Коммит cc5d7097ba
1 изменённых файлов: 5 добавлений и 4 удалений

Просмотреть файл

@ -231,7 +231,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) {
@ -260,12 +260,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;