is_range_mapped() uses getline() to read /proc/self/maps line by
line, but never frees the buffer it allocates. Every exit path
(parse failure, match found, or reaching EOF) returns without
calling free(line), leaking the buffer on each call. The function
is called multiple times in this test, so the leak accumulates
across calls.

Free line before returning.

Signed-off-by: Anshuman <[email protected]>
---
 tools/testing/selftests/mm/mremap_test.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/mm/mremap_test.c 
b/tools/testing/selftests/mm/mremap_test.c
index 131d9d6db..779ef2d5f 100644
--- a/tools/testing/selftests/mm/mremap_test.c
+++ b/tools/testing/selftests/mm/mremap_test.c
@@ -156,6 +156,7 @@ static bool is_range_mapped(FILE *maps_fp, unsigned long 
start,
                }
        }
 
+       free(line);
        return success;
 }
 
-- 
2.55.0


Reply via email to