Commit 904e6b26 authored by Nikos Tsironis's avatar Nikos Tsironis Committed by Mike Snitzer

dm era: Fix bitset memory leaks

Deallocate the memory allocated for the in-core bitsets when destroying
the target and in error paths.

Fixes: eec40579 ("dm: add era target")
Cc: stable@vger.kernel.org # v3.15+
Signed-off-by: default avatarNikos Tsironis <ntsironis@arrikto.com>
Reviewed-by: default avatarMing-Hung Tsai <mtsai@redhat.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent c8e846ff
...@@ -47,6 +47,7 @@ struct writeset { ...@@ -47,6 +47,7 @@ struct writeset {
static void writeset_free(struct writeset *ws) static void writeset_free(struct writeset *ws)
{ {
vfree(ws->bits); vfree(ws->bits);
ws->bits = NULL;
} }
static int setup_on_disk_bitset(struct dm_disk_bitset *info, static int setup_on_disk_bitset(struct dm_disk_bitset *info,
...@@ -811,6 +812,8 @@ static struct era_metadata *metadata_open(struct block_device *bdev, ...@@ -811,6 +812,8 @@ static struct era_metadata *metadata_open(struct block_device *bdev,
static void metadata_close(struct era_metadata *md) static void metadata_close(struct era_metadata *md)
{ {
writeset_free(&md->writesets[0]);
writeset_free(&md->writesets[1]);
destroy_persistent_data_objects(md); destroy_persistent_data_objects(md);
kfree(md); kfree(md);
} }
...@@ -848,6 +851,7 @@ static int metadata_resize(struct era_metadata *md, void *arg) ...@@ -848,6 +851,7 @@ static int metadata_resize(struct era_metadata *md, void *arg)
r = writeset_alloc(&md->writesets[1], *new_size); r = writeset_alloc(&md->writesets[1], *new_size);
if (r) { if (r) {
DMERR("%s: writeset_alloc failed for writeset 1", __func__); DMERR("%s: writeset_alloc failed for writeset 1", __func__);
writeset_free(&md->writesets[0]);
return r; return r;
} }
...@@ -858,6 +862,8 @@ static int metadata_resize(struct era_metadata *md, void *arg) ...@@ -858,6 +862,8 @@ static int metadata_resize(struct era_metadata *md, void *arg)
&value, &md->era_array_root); &value, &md->era_array_root);
if (r) { if (r) {
DMERR("%s: dm_array_resize failed", __func__); DMERR("%s: dm_array_resize failed", __func__);
writeset_free(&md->writesets[0]);
writeset_free(&md->writesets[1]);
return r; return r;
} }
......
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