[LTP] [PATCH 2/3] realtime/librttest: Fix memory leaks

Joerg Vehlow lkml@jv-coder.de
Mon Nov 15 09:15:25 CET 2021


From: Joerg Vehlow <joerg.vehlow@aox-tech.de>

Signed-off-by: Joerg Vehlow <joerg.vehlow@aox-tech.de>
---
 testcases/realtime/lib/librttest.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/testcases/realtime/lib/librttest.c b/testcases/realtime/lib/librttest.c
index 89e2bfc6e..eaa623b72 100644
--- a/testcases/realtime/lib/librttest.c
+++ b/testcases/realtime/lib/librttest.c
@@ -226,6 +226,8 @@ int rt_init_long(const char *options, const struct option *longopts,
 
 	calibrate_busyloop();
 
+	free(all_options);
+
 	/*
 	 * atexit() order matters here - buffer_print() will be called before
 	 * buffer_fini().
@@ -378,6 +380,7 @@ void join_thread(int i)
 		if (t->pthread)
 			pthread_join(t->pthread, NULL);
 		list_del(&t->_threads);
+		free(t);
 	}
 }
 
@@ -397,6 +400,7 @@ void join_threads(void)
 		if (p->pthread)
 			pthread_join(p->pthread, NULL);
 		list_del(&p->_threads);
+		free(p);
 	}
 }
 
-- 
2.25.1



More information about the ltp mailing list