Skip to content

Commit

Permalink
dm thin: fix memory leak in process_prepared_mapping error paths
Browse files Browse the repository at this point in the history
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 <ejt@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
  • Loading branch information
Joe Thornber authored and Alasdair G Kergon committed Jul 27, 2012
1 parent c66029f commit 905386f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/md/dm-thin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/*
Expand All @@ -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;
}

/*
Expand All @@ -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);
}
Expand Down

0 comments on commit 905386f

Please sign in to comment.