From d0e50033fd80abf5087804960ac66fb49d22de9d Mon Sep 17 00:00:00 2001 From: Petri Latvala Date: Thu, 7 Mar 2019 14:37:24 +0200 Subject: lib/aux: Plug memory leak in get_suspend_test Free test_line in all paths out of the function. v2: Avoid freeing too soon (Chris) Signed-off-by: Petri Latvala Cc: Chris Wilson Reviewed-by: Chris Wilson --- lib/igt_aux.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/igt_aux.c') 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; } -- cgit v1.2.3