[PATCH] selftests/mm: fix line buffer leak in mremap_test is_range_mapped()
From: Anshuman
Date: Wed Aug 26 2026 - 02:15:45 EST
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 <anshumantewari123@xxxxxxxxx>
---
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