Skip to contentSkip to conversation

libtracefs: Do not free filter regex if it was not created in update_filter()

PATCH New Steven Rostedt 1 participant 1 message Jun 9, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libtracefs: Do not free filter regex if it was not created in update_filter()

From: "Steven Rostedt (VMware)" <[email protected]>

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")
---
 src/tracefs-tools.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
src/tracefs-tools.c +2 -1
index 993fb3c..f202a15 100644
@@ -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);
Signature · 1 line
2.29.2