Skip to content

Commit 5991bfa

Browse files
committed
block: fix folio leak in bio_iov_iter_bounce_read()
If iov_iter_extract_bvecs() returns an error or zero bytes extracted, then the folio allocated is leaked on return. Ensure it's put before returning. Fixes: 8dd5e7c ("block: add helpers to bounce buffer an iov_iter into bios") Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 5b88af7 commit 5991bfa

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

block/bio.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1382,8 +1382,10 @@ static int bio_iov_iter_bounce_read(struct bio *bio, struct iov_iter *iter)
13821382
ret = iov_iter_extract_bvecs(iter, bio->bi_io_vec + 1, len,
13831383
&bio->bi_vcnt, bio->bi_max_vecs - 1, 0);
13841384
if (ret <= 0) {
1385-
if (!bio->bi_vcnt)
1385+
if (!bio->bi_vcnt) {
1386+
folio_put(folio);
13861387
return ret;
1388+
}
13871389
break;
13881390
}
13891391
len -= ret;

0 commit comments

Comments
 (0)