[PATCH 05/23] libtracefs: Free tracing_dir in case of remount

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx>

On remount, the tracing directory may move, and the tracing_dir needs to be
updated. If tracing_dir is the same it is simply returned, but if it is not,
it has to be calculated again. This was fixed but if it was changed, the old
tracing_dir was never freed.

Always free the tracing_dir before calculating a new one. This also requires
changing the type by removing the "const" attribute.

Fixes: 92c9292a ("libtracefs: Have tracefs_{tracing,debug}_dir() make sure it's still mounted")
Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
---
 src/tracefs-utils.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/tracefs-utils.c b/src/tracefs-utils.c
index ef90677cf617..e67b698f5b99 100644
--- a/src/tracefs-utils.c
+++ b/src/tracefs-utils.c
@@ -248,7 +248,7 @@ static int test_dir(const char *dir, const char *file)
  */
 const char *tracefs_tracing_dir(void)
 {
-	static const char *tracing_dir;
+	static char *tracing_dir;
 
 	/* Do not check custom_tracing_dir */
 	if (custom_tracing_dir)
@@ -257,6 +257,7 @@ const char *tracefs_tracing_dir(void)
 	if (tracing_dir && test_dir(tracing_dir, "trace"))
 		return tracing_dir;
 
+	free(tracing_dir);
 	tracing_dir = find_tracing_dir(false, true);
 	return tracing_dir;
 }
-- 
2.42.0





[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux