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.
Showing the changes to block (1 of 1 file). Show all
Unified · Split
| @@ -1382,8 +1382,10 @@ static int bio_iov_iter_bounce_read(struct bio *bio, struct iov_iter *iter) · 1381 unmodified lines | ||
| 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; |