History

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.

Jens Axboe committed 9 months ago

Commit 5991bfa1 parent 5b88af71 file · +3 −1Browse files

Showing the changes to block (1 of 1 file). Show all

Unified · Split

block/bio.c+3−1
@@ -1382,8 +1382,10 @@ static int bio_iov_iter_bounce_read(struct bio *bio, struct iov_iter *iter) · 1381 unmodified lines
1382 ret = iov_iter_extract_bvecs(iter, bio->bi_io_vec + 1, len,1382 ret = iov_iter_extract_bvecs(iter, bio->bi_io_vec + 1, len,
1383 &bio->bi_vcnt, bio->bi_max_vecs - 1, 0);1383 &bio->bi_vcnt, bio->bi_max_vecs - 1, 0);
1384 if (ret <= 0) {1384 if (ret <= 0) {
1385 if (!bio->bi_vcnt)1385 if (!bio->bi_vcnt) {
1386 folio_put(folio);
1386 return ret;1387 return ret;
1388 }
1387 break;1389 break;
1388 }1390 }
1389 len -= ret;1391 len -= ret;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t