Skip to content

Commit 03aaae7

Browse files
snitmkergon
authored andcommitted
dm thin: reinstate missing mempool_free in cell_release_singleton
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 <[email protected]> Signed-off-by: Alasdair G Kergon <[email protected]>
1 parent d48b97b commit 03aaae7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/md/dm-thin.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,10 @@ static void __cell_release(struct cell *cell, struct bio_list *inmates)
279279

280280
hlist_del(&cell->list);
281281

282-
bio_list_add(inmates, cell->holder);
283-
bio_list_merge(inmates, &cell->bios);
282+
if (inmates) {
283+
bio_list_add(inmates, cell->holder);
284+
bio_list_merge(inmates, &cell->bios);
285+
}
284286

285287
mempool_free(cell, prison->cell_pool);
286288
}
@@ -303,9 +305,10 @@ static void cell_release(struct cell *cell, struct bio_list *bios)
303305
*/
304306
static void __cell_release_singleton(struct cell *cell, struct bio *bio)
305307
{
306-
hlist_del(&cell->list);
307308
BUG_ON(cell->holder != bio);
308309
BUG_ON(!bio_list_empty(&cell->bios));
310+
311+
__cell_release(cell, NULL);
309312
}
310313

311314
static void cell_release_singleton(struct cell *cell, struct bio *bio)

0 commit comments

Comments
 (0)