selftests/mm: fix line buffer leak in mremap_test is_range_mapped()

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.

Link: https://lore.kernel.org/20260826061300.14038-1-anshumantewari123@gmail.com
Signed-off-by: Anshuman <anshumantewari123@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: SJ Park <sj@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
This commit is contained in:
Anshuman 2026-08-26 11:43:00 +05:30 committed by Andrew Morton
parent 585bb36e6a
commit 576446e2df

View File

@ -156,6 +156,7 @@ static bool is_range_mapped(FILE *maps_fp, unsigned long start,
}
}
free(line);
return success;
}