Blame libtracefs-Prevent-memory-leak-in-tracefs_instance_c.patch

Jerome Marchand 3772ca
From 5e5b2a760b13aeecd72da9bda392d2d3510fc409 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:24 +0200
Jerome Marchand 3772ca
Subject: [PATCH 10/15] libtracefs: Prevent memory leak in
Jerome Marchand 3772ca
 tracefs_instance_create()
Jerome Marchand 3772ca
Jerome Marchand 3772ca
Free the path of the instance directory in the error path.
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-11-jmarchan@redhat.com
Jerome Marchand 3772ca
Jerome Marchand 3772ca
Fixes: ebbb8507de560 libtracefs: Combine allocate and create APIs into one
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-instance.c | 1 +
Jerome Marchand 3772ca
 1 file changed, 1 insertion(+)
Jerome Marchand 3772ca
Jerome Marchand 3772ca
diff --git a/src/tracefs-instance.c b/src/tracefs-instance.c
Jerome Marchand 3772ca
index 9a26708..dd7decd 100644
Jerome Marchand 3772ca
--- a/src/tracefs-instance.c
Jerome Marchand 3772ca
+++ b/src/tracefs-instance.c
Jerome Marchand 3772ca
@@ -217,6 +217,7 @@ struct tracefs_instance *tracefs_instance_create(const char *name)
Jerome Marchand 3772ca
 	return inst;
Jerome Marchand 3772ca
 
Jerome Marchand 3772ca
 error:
Jerome Marchand 3772ca
+	tracefs_put_tracing_file(path);
Jerome Marchand 3772ca
 	tracefs_instance_free(inst);
Jerome Marchand 3772ca
 	return NULL;
Jerome Marchand 3772ca
 }
Jerome Marchand 3772ca
-- 
Jerome Marchand 3772ca
2.45.2
Jerome Marchand 3772ca