Commit 69d85819 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] bio_dirty_fn() page leak fix

bio_dirty_fn() needs to drop its ref against each remaining page in the BIO
before releasing the BIO.
parent 1669e6e9
...@@ -558,6 +558,19 @@ void bio_set_pages_dirty(struct bio *bio) ...@@ -558,6 +558,19 @@ void bio_set_pages_dirty(struct bio *bio)
} }
} }
void bio_release_pages(struct bio *bio)
{
struct bio_vec *bvec = bio->bi_io_vec;
int i;
for (i = 0; i < bio->bi_vcnt; i++) {
struct page *page = bvec[i].bv_page;
if (page)
put_page(page);
}
}
/* /*
* bio_check_pages_dirty() will check that all the BIO's pages are still dirty. * bio_check_pages_dirty() will check that all the BIO's pages are still dirty.
* If they are, then fine. If, however, some pages are clean then they must * If they are, then fine. If, however, some pages are clean then they must
...@@ -592,6 +605,7 @@ static void bio_dirty_fn(void *data) ...@@ -592,6 +605,7 @@ static void bio_dirty_fn(void *data)
struct bio *next = bio->bi_private; struct bio *next = bio->bi_private;
bio_set_pages_dirty(bio); bio_set_pages_dirty(bio);
bio_release_pages(bio);
bio_put(bio); bio_put(bio);
bio = next; bio = next;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment