[PATCH] tools/mm: Free the allocated memory
From: Liu Jing
Date: Tue Oct 22 2024 - 09:13:59 EST
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