Blame libtraceevent-prevent-a-memory-leak-in-tep_plugin_ad.patch

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