From e229a3af39e4018eaf136c74f5b3eb15016d5cf3 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Wed, 25 Jul 2012 09:25:18 +1000 Subject: [PATCH] Fix memory leak in process_prepared_mapping by always freeing the dm_thin_new_mapping structs from the mapping_pool mempool on the error paths. Signed-off-by: Joe Thornber Cc: stable@vger.kernel.org Signed-off-by: Mike Snitzer Signed-off-by: Alasdair G Kergon --- drivers/md/dm-thin.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c index 6d0fb34a0308..14adc485abd0 100644 --- a/drivers/md/dm-thin.c +++ b/drivers/md/dm-thin.c @@ -870,7 +870,7 @@ static void process_prepared_mapping(struct dm_thin_new_mapping *m) if (m->err) { cell_error(m->cell); - return; + goto out; } /* @@ -882,7 +882,7 @@ static void process_prepared_mapping(struct dm_thin_new_mapping *m) if (r) { DMERR("dm_thin_insert_block() failed"); cell_error(m->cell); - return; + goto out; } /* @@ -897,6 +897,7 @@ static void process_prepared_mapping(struct dm_thin_new_mapping *m) } else cell_defer(tc, m->cell, m->data_block); +out: list_del(&m->list); mempool_free(m, tc->pool->mapping_pool); } -- 2.39.5