diff options
| author | Jens Axboe <axboe@kernel.dk> | 2026-02-12 04:07:41 -0700 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2026-02-12 04:15:02 -0700 |
| commit | 5991bfa3f88ec8d67fa3f552c19c39ff37a4e67b (patch) | |
| tree | 9045db3724bcc685a5975439dce9ed5c24dc47c8 | |
| parent | 5b88af7113feba2f0ae3402bb57cb5c94eea7dc3 (diff) | |
| download | linux-5991bfa3f88ec8d67fa3f552c19c39ff37a4e67b.tar.gz linux-5991bfa3f88ec8d67fa3f552c19c39ff37a4e67b.zip | |
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>
| -rw-r--r-- | block/bio.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/block/bio.c b/block/bio.c index b291b9aaeee1..8203bb7455a9 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1382,8 +1382,10 @@ static int bio_iov_iter_bounce_read(struct bio *bio, struct iov_iter *iter) ret = iov_iter_extract_bvecs(iter, bio->bi_io_vec + 1, len, &bio->bi_vcnt, bio->bi_max_vecs - 1, 0); if (ret <= 0) { - if (!bio->bi_vcnt) + if (!bio->bi_vcnt) { + folio_put(folio); return ret; + } break; } len -= ret; |
