[igt-dev] [PATCH i-g-t v2 2/5] lib/aux: Plug memory leak in get_suspend_test

Petri Latvala petri.latvala at intel.com
Thu Mar 7 12:37:24 UTC 2019


Free test_line in all paths out of the function.

v2: Avoid freeing too soon (Chris)

Signed-off-by: Petri Latvala <petri.latvala at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
---
 lib/igt_aux.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index e5d41e32..6eaf546e 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -718,8 +718,10 @@ static enum igt_suspend_test get_suspend_test(int power_dir)
 			break;
 		}
 
-	if (!test_name)
+	if (!test_name) {
+	  	free(test_line);
 		return SUSPEND_TEST_NONE;
+	}
 
 	for (test = SUSPEND_TEST_NONE; test < SUSPEND_TEST_NUM; test++)
 		if (strcmp(suspend_test_name[test], test_name) == 0)
@@ -728,7 +730,6 @@ static enum igt_suspend_test get_suspend_test(int power_dir)
 	igt_assert(test < SUSPEND_TEST_NUM);
 
 	free(test_line);
-
 	return test;
 }
 
-- 
2.19.1



More information about the igt-dev mailing list