Skip to content

Commit

Permalink
blkdev: __blkdev_direct_IO_simple: fix leak in error case
Browse files Browse the repository at this point in the history
Fixes: 72ecad2 ("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>
  • Loading branch information
Martin Wilck authored and Jens Axboe committed Jul 26, 2018
1 parent b403ea2 commit 9362dd1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions fs/block_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9362dd1

Please sign in to comment.