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

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
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;

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