Skip to content

Commit 9362dd1

Browse files
mwilckaxboe
authored andcommitted
blkdev: __blkdev_direct_IO_simple: fix leak in error case
Fixes: 72ecad2 ("block: support a full bio worth of IO for simplified bdev direct-io") Reviewed-by: Ming Lei <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Martin Wilck <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent b403ea2 commit 9362dd1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

fs/block_dev.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
220220

221221
ret = bio_iov_iter_get_pages(&bio, iter);
222222
if (unlikely(ret))
223-
return ret;
223+
goto out;
224224
ret = bio.bi_iter.bi_size;
225225

226226
if (iov_iter_rw(iter) == READ) {
@@ -249,12 +249,13 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
249249
put_page(bvec->bv_page);
250250
}
251251

252-
if (vecs != inline_vecs)
253-
kfree(vecs);
254-
255252
if (unlikely(bio.bi_status))
256253
ret = blk_status_to_errno(bio.bi_status);
257254

255+
out:
256+
if (vecs != inline_vecs)
257+
kfree(vecs);
258+
258259
bio_uninit(&bio);
259260

260261
return ret;

0 commit comments

Comments
 (0)