Skip to content

Commit

Permalink
dm thin: reinstate missing mempool_free in cell_release_singleton
Browse files Browse the repository at this point in the history
Fix a significant memory leak inadvertently introduced during
simplification of cell_release_singleton() in commit
6f94a4c ("dm thin: fix stacked bi_next
usage").

A cell's hlist_del() must be accompanied by a mempool_free().
Use __cell_release() to do this, like before.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
  • Loading branch information
Mike Snitzer authored and Alasdair G Kergon committed May 12, 2012
1 parent d48b97b commit 03aaae7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/md/dm-thin.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,10 @@ static void __cell_release(struct cell *cell, struct bio_list *inmates)

hlist_del(&cell->list);

bio_list_add(inmates, cell->holder);
bio_list_merge(inmates, &cell->bios);
if (inmates) {
bio_list_add(inmates, cell->holder);
bio_list_merge(inmates, &cell->bios);
}

mempool_free(cell, prison->cell_pool);
}
Expand All @@ -303,9 +305,10 @@ static void cell_release(struct cell *cell, struct bio_list *bios)
*/
static void __cell_release_singleton(struct cell *cell, struct bio *bio)
{
hlist_del(&cell->list);
BUG_ON(cell->holder != bio);
BUG_ON(!bio_list_empty(&cell->bios));

__cell_release(cell, NULL);
}

static void cell_release_singleton(struct cell *cell, struct bio *bio)
Expand Down

0 comments on commit 03aaae7

Please sign in to comment.