1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-30 17:18:21 +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:
Bryn M. Reeves 2015-08-10 10:15:22 +01:00
parent 1134de3c89
commit f9f5aac123

View File

@ -94,10 +94,10 @@ struct dm_stats *dm_stats_create(const char *program_id)
{
struct dm_stats *dms = NULL;
if (!(dms = dm_malloc(sizeof(*dms))))
if (!(dms = dm_zalloc(sizeof(*dms))))
return_NULL;
if (!(dms->mem = dm_pool_create("stats_pool", 4096)))
return_NULL;
goto_out;
if (!program_id || !strlen(program_id))
dms->program_id = _program_id_from_proc();
@ -117,6 +117,9 @@ struct dm_stats *dm_stats_create(const char *program_id)
dms->regions = NULL;
return dms;
out:
dm_free(dms);
return NULL;
}
/**