linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libtracefs: Do not free filter regex if it was not created in update_filter()
@ 2021-06-09 13:24 Steven Rostedt
  0 siblings, 0 replies; only message in thread
From: Steven Rostedt @ 2021-06-09 13:24 UTC (permalink / raw)
  To: linux-trace-devel

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

If the filter is NULL and reset is set in update_filter(), the filter
regex is not created, in which case it must not be freed, as the call to
regfree() does not handle a case of an uninitialized regex.

Fixes: 8f26581f ("libtracefs: Allow filter be NULL if RESET flag is set")
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 src/tracefs-tools.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/tracefs-tools.c b/src/tracefs-tools.c
index 993fb3c..f202a15 100644
--- a/src/tracefs-tools.c
+++ b/src/tracefs-tools.c
@@ -816,7 +816,8 @@ static int update_filter(const char *filter_path, int *fd,
 	}
 
  out_free:
-	regfree(&func_filter.re);
+	if (filter)
+		regfree(&func_filter.re);
 	free_func_list(func_list);
  out:
 	pthread_mutex_unlock(lock);
-- 
2.29.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-09 13:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09 13:24 [PATCH] libtracefs: Do not free filter regex if it was not created in update_filter() Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).