Re: [PATCH] selftests/mm: fix line buffer leak in mremap_test is_range_mapped()

From: Anshuman Tewari

Date: Wed Aug 26 2026 - 16:43:06 EST


Thanks, David — appreciate the ack.

Anshuman

On Wed, 26 Aug 2026 at 13:08, David Hildenbrand (Arm) <david@xxxxxxxxxx> wrote:
>
> On 8/26/26 08:13, Anshuman wrote:
> > 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>
> > ---
>
> Looks good, I don't think Fixes is needed (even though called multiple times,
> the effective waste should not be relevant on any realistic system).
>
> Thanks!
>
> Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
>
> --
> Cheers,
>
> David