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