The comm_str memory needs to be freed if the search_pattern function call fails in get_comm Signed-off-by: Liu Jing <liujing@xxxxxxxxxxxxxxxxxxxx> diff --git a/tools/mm/page_owner_sort.c b/tools/mm/page_owner_sort.c index e1f264444342..724d024e0756 100644 --- a/tools/mm/page_owner_sort.c +++ b/tools/mm/page_owner_sort.c @@ -377,6 +377,7 @@ static char *get_comm(char *buf) if (errno != 0) { if (debug_on) fprintf(stderr, "wrong comm in follow buf:\n%s\n", buf); + free (comm_str); return NULL; } -- 2.27.0