The handle returned by dlopen() isn't close if an error occures afterward. Call dlclose() in the error path. Fixes a RESOURCE_LEAK error (CWE-772) Signed-off-by: Jerome Marchand <jmarchan@xxxxxxxxxx> --- src/event-plugin.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/event-plugin.c b/src/event-plugin.c index f42243f..7f94107 100644 --- a/src/event-plugin.c +++ b/src/event-plugin.c @@ -474,7 +474,7 @@ load_plugin(struct tep_handle *tep, const char *path, while (options->name) { ret = update_option(alias, options); if (ret < 0) - goto out_free; + goto out_close; options++; } } @@ -483,13 +483,13 @@ load_plugin(struct tep_handle *tep, const char *path, if (!func) { tep_warning("could not find func '%s' in plugin '%s'\n%s\n", TEP_PLUGIN_LOADER_NAME, plugin, dlerror()); - goto out_free; + goto out_close; } list = malloc(sizeof(*list)); if (!list) { tep_warning("could not allocate plugin memory\n"); - goto out_free; + goto out_close; } list->next = *plugin_list; @@ -501,6 +501,8 @@ load_plugin(struct tep_handle *tep, const char *path, func(tep); return; +out_close: + dlclose(handle); out_free: free(plugin); } -- 2.45.1