Skip to content

Commit 904e6b2

Browse files
ntsironsnitm
authored andcommitted
dm era: Fix bitset memory leaks
Deallocate the memory allocated for the in-core bitsets when destroying the target and in error paths. Fixes: eec4057 ("dm: add era target") Cc: [email protected] # v3.15+ Signed-off-by: Nikos Tsironis <[email protected]> Reviewed-by: Ming-Hung Tsai <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent c8e846f commit 904e6b2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/md/dm-era-target.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct writeset {
4747
static void writeset_free(struct writeset *ws)
4848
{
4949
vfree(ws->bits);
50+
ws->bits = NULL;
5051
}
5152

5253
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,
811812

812813
static void metadata_close(struct era_metadata *md)
813814
{
815+
writeset_free(&md->writesets[0]);
816+
writeset_free(&md->writesets[1]);
814817
destroy_persistent_data_objects(md);
815818
kfree(md);
816819
}
@@ -848,6 +851,7 @@ static int metadata_resize(struct era_metadata *md, void *arg)
848851
r = writeset_alloc(&md->writesets[1], *new_size);
849852
if (r) {
850853
DMERR("%s: writeset_alloc failed for writeset 1", __func__);
854+
writeset_free(&md->writesets[0]);
851855
return r;
852856
}
853857

@@ -858,6 +862,8 @@ static int metadata_resize(struct era_metadata *md, void *arg)
858862
&value, &md->era_array_root);
859863
if (r) {
860864
DMERR("%s: dm_array_resize failed", __func__);
865+
writeset_free(&md->writesets[0]);
866+
writeset_free(&md->writesets[1]);
861867
return r;
862868
}
863869

0 commit comments

Comments
 (0)