Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 8dd5e7c75d7b ("block: add helpers to bounce buffer an iov_iter into bios")
Signed-off-by: Jens Axboe <axboe@kernel.dk>

+3 -1
+3 -1
block/bio.c
··· 1382 1382 ret = iov_iter_extract_bvecs(iter, bio->bi_io_vec + 1, len, 1383 1383 &bio->bi_vcnt, bio->bi_max_vecs - 1, 0); 1384 1384 if (ret <= 0) { 1385 - if (!bio->bi_vcnt) 1385 + if (!bio->bi_vcnt) { 1386 + folio_put(folio); 1386 1387 return ret; 1388 + } 1387 1389 break; 1388 1390 } 1389 1391 len -= ret;