From c84155f7dfedeb0e0c0c00f5fae7bad67f494de7 Mon Sep 17 00:00:00 2001 From: Jerome Marchand Date: Fri, 7 Jun 2024 18:05:41 +0200 Subject: [PATCH 5/7] libtraceevent: prevent a memory leak in tep_plugin_add_option() If parse_option_name() fails, plugin, which now points to the previous value of option_str isn't freed. Go to out_free if that happens. Fixes a RESOURCE_LEAK error (CWE-772) Link: https://lore.kernel.org/linux-trace-devel/20240607160542.46152-4-jmarchan@redhat.com Fixes: 442ac241bef96 ("libtraceevent: Handle strdup() error in parse_option_name()") Signed-off-by: Jerome Marchand Signed-off-by: Steven Rostedt (Google) --- src/event-plugin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/event-plugin.c b/src/event-plugin.c index 7f94107..c944204 100644 --- a/src/event-plugin.c +++ b/src/event-plugin.c @@ -327,7 +327,7 @@ int tep_plugin_add_option(const char *name, const char *val) return -ENOMEM; if (parse_option_name(&option_str, &plugin) < 0) - return -ENOMEM; + goto out_free; /* If the option exists, update the val */ for (op = trace_plugin_options; op; op = op->next) { -- 2.45.2