diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2015-08-10 10:15:22 +0100 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2015-08-10 20:20:30 +0100 |
commit | f9f5aac123d2244daeff92a692a03da3fea6bd74 (patch) | |
tree | 5aa29b67f43aa92c5e78c655801581de6d4b3cc9 | |
parent | 1134de3c89c5a07699365031d0cb88383e365929 (diff) | |
download | lvm2-f9f5aac123d2244daeff92a692a03da3fea6bd74.tar.gz |
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.
-rw-r--r-- | libdm/libdm-stats.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c index 64ca23f57..a672e0562 100644 --- a/libdm/libdm-stats.c +++ b/libdm/libdm-stats.c @@ -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; } /** |