mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
libdm: fix stats handle leak in dm_stats_create (Coverity)
Make sure the newly created handle is freed if we are unable to also create the pool for it. tools/dmsetup.c: 4255 in _stats_list() - Variable "dms" going out of scope leaks the storage it points to.
This commit is contained in:
parent
1134de3c89
commit
f9f5aac123
@ -94,10 +94,10 @@ struct dm_stats *dm_stats_create(const char *program_id)
|
|||||||
{
|
{
|
||||||
struct dm_stats *dms = NULL;
|
struct dm_stats *dms = NULL;
|
||||||
|
|
||||||
if (!(dms = dm_malloc(sizeof(*dms))))
|
if (!(dms = dm_zalloc(sizeof(*dms))))
|
||||||
return_NULL;
|
return_NULL;
|
||||||
if (!(dms->mem = dm_pool_create("stats_pool", 4096)))
|
if (!(dms->mem = dm_pool_create("stats_pool", 4096)))
|
||||||
return_NULL;
|
goto_out;
|
||||||
|
|
||||||
if (!program_id || !strlen(program_id))
|
if (!program_id || !strlen(program_id))
|
||||||
dms->program_id = _program_id_from_proc();
|
dms->program_id = _program_id_from_proc();
|
||||||
@ -117,6 +117,9 @@ struct dm_stats *dm_stats_create(const char *program_id)
|
|||||||
dms->regions = NULL;
|
dms->regions = NULL;
|
||||||
|
|
||||||
return dms;
|
return dms;
|
||||||
|
out:
|
||||||
|
dm_free(dms);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user