mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-22 07:27:12 +08:00
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: 8dd5e7c75d ("block: add helpers to bounce buffer an iov_iter into bios")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
@@ -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,
|
ret = iov_iter_extract_bvecs(iter, bio->bi_io_vec + 1, len,
|
||||||
&bio->bi_vcnt, bio->bi_max_vecs - 1, 0);
|
&bio->bi_vcnt, bio->bi_max_vecs - 1, 0);
|
||||||
if (ret <= 0) {
|
if (ret <= 0) {
|
||||||
if (!bio->bi_vcnt)
|
if (!bio->bi_vcnt) {
|
||||||
|
folio_put(folio);
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
len -= ret;
|
len -= ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user