From: Steven Rostedt <rostedt@goodmis.org>
To: "linux-trace-devel@vger.kernel.org" <linux-trace-devel@vger.kernel.org>
Subject: [PATCH] libtracefs: Do not free filter regex if it was not created in update_filter()
Date: Wed, 9 Jun 2021 09:24:22 -0400 [thread overview]
Message-ID: <20210609092422.65edc8c2@oasis.local.home> (raw)
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
reply other threads:[~2021-06-09 13:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210609092422.65edc8c2@oasis.local.home \
--to=rostedt@goodmis.org \
--cc=linux-trace-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).