diff --git a/ldms/src/ldmsd/ldmsd_config.c b/ldms/src/ldmsd/ldmsd_config.c index 3ec25e201..345e1aa14 100644 --- a/ldms/src/ldmsd/ldmsd_config.c +++ b/ldms/src/ldmsd/ldmsd_config.c @@ -330,16 +330,22 @@ int ldmsd_config_plugin(char *plugin_name, avl = calloc(1, sizeof(*avl)); kwl = calloc(1, sizeof(*kwl)); - if (!avl || !kwl) - return ENOMEM; + if (!avl || !kwl) { + rc = ENOMEM; + goto err; + } avl->av_list = av_copy(_av_list); kwl->av_list = av_copy(_kw_list); - if (!avl->av_list || !kwl->av_list) - return ENOMEM; + if (!avl->av_list || !kwl->av_list) { + rc = ENOMEM; + goto err; + } pi = ldmsd_get_plugin(plugin_name); - if (!pi) - return ENOENT; + if (!pi) { + rc = ENOENT; + goto err; + } pthread_mutex_lock(&pi->lock); rc = pi->plugin->config(pi->plugin, _kw_list, _av_list); @@ -347,6 +353,18 @@ int ldmsd_config_plugin(char *plugin_name, TAILQ_INSERT_TAIL(&pi->plugin->avl_q, avl, entry); pthread_mutex_unlock(&pi->lock); return rc; +err: + if (avl) { + if (avl->av_list) + av_free(avl->av_list); + free(avl); + } + if (kwl) { + if (kwl->av_list) + av_free(kwl->av_list); + free(kwl); + } + return rc; } int _ldmsd_set_udata(ldms_set_t set, char *metric_name, uint64_t udata,