Re: [PATCH v3] tools/mm/page_owner_sort: free per-record allocations

From: Vishal Moola

Date: Mon Jun 15 2026 - 08:26:43 EST


On Fri, Jun 12, 2026 at 01:50:17PM +0800, Yichong Chen wrote:
> add_list() allocates comm and txt for each page owner record, but the
> cleanup path only frees the outer list array. This leaks both buffers for
> every retained record.
>
> Free partial allocations in add_list(), discarded records during
> culling, and retained records on exit. Return explicit error, skip, and
> match results from filter_record() to handle get_comm() failures.

Nit: IMO its bad practice to rename function names without stating it in
the commit log. Especially if you reference its behavior in that commit
log.

>
> Signed-off-by: Yichong Chen <chenyichong@xxxxxxxxxxxxx>
> ---

I like the enum approach. Splitting it out and having this as a 2-patch
series would have made sense too (since doing it this way has
2 distinct logical changes).

Whether combined or split, you can add my tag:

Reviewed-by: Vishal Moola <vishal.moola@xxxxxxxxx>