You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.2 KiB
39 lines
1.2 KiB
3 months ago
|
From 1c9539491d2440eab01ffc3b7a616502ef22cc1b Mon Sep 17 00:00:00 2001
|
||
|
From: Jerome Marchand <jmarchan@redhat.com>
|
||
|
Date: Thu, 6 Jun 2024 17:38:17 +0200
|
||
|
Subject: [PATCH 03/15] libtracefs: Prevent a memory leak in update_fields()
|
||
|
|
||
|
In update_fields() p isn't freed is store_str fails. Since p is to be
|
||
|
freed whatever the result of store_str() might be, move the call to
|
||
|
free() before checking field_name.
|
||
|
|
||
|
Fixes a RESSOURCE_LEAK error (CWE-772)
|
||
|
|
||
|
Link: https://lore.kernel.org/linux-trace-devel/20240606153830.2666120-4-jmarchan@redhat.com
|
||
|
|
||
|
Fixes: fa51df99ad21d ("libtracefs: Allow for simple SQL statements to create a histogram")
|
||
|
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
|
||
|
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
|
||
|
---
|
||
|
src/tracefs-sqlhist.c | 2 +-
|
||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||
|
|
||
|
diff --git a/src/tracefs-sqlhist.c b/src/tracefs-sqlhist.c
|
||
|
index ecf09ce..c7b9eff 100644
|
||
|
--- a/src/tracefs-sqlhist.c
|
||
|
+++ b/src/tracefs-sqlhist.c
|
||
|
@@ -810,9 +810,9 @@ static int update_fields(struct tep_handle *tep,
|
||
|
if (!p)
|
||
|
return -1;
|
||
|
field_name = store_str(sb, p);
|
||
|
+ free((char *)p);
|
||
|
if (!field_name)
|
||
|
return -1;
|
||
|
- free((char *)p);
|
||
|
}
|
||
|
|
||
|
tfield = tep_find_any_field(event, field_name);
|
||
|
--
|
||
|
2.45.2
|
||
|
|