cpupower: fix memory leak in print_{on,off}line_cpus()
PATCH 1/1 cpupower: fix memory leak in print_{on,off}line_cpus()
{on,off}online_cpus_str not free after use
Suggested-by Jun Zhan <[email protected]>
Signed-off-by Cryolitia PukNgae <[email protected]>
--- tools/power/cpupower/utils/helpers/misc.c | 4 ++++ 1 file changed, 4 insertions(+)
tools/power/cpupower/utils/helpers/misc.c +4 -0
@@ -213,6 +213,8 @@ void print_online_cpus(void)bitmask_displaylist (online_cpus_str, str_len, online_cpus);printf (_ ("Following CPUs are online:\n%s\n" ), online_cpus_str); } + +free (online_cpus_str); }/* print_offline_cpus
@@ -232,6 +234,8 @@ void print_offline_cpus(void)printf (_ ("Following CPUs are offline:\n%s\n" ), offline_cpus_str);printf (_ ("cpupower set operation was not performed on them\n" )); } + +free (offline_cpus_str); }/*
---
base-commit: fab1beda7597fac1cecc01707d55eadb6bbe773c
change-id: 20250827-power-memoryleak-75c692220277
Best regards,
Signature · 1 line
Cryolitia PukNgae <[email protected]>
Shuah Khan
maintainerQuoted 3 lines · On 8/27/25 03:46, Cryolitia PukNgae via B4 Relay wrote:
From: Cryolitia PukNgae <[email protected]>
{on,off}online_cpus_str not free after use
How did you find this problem? The memory is released when cpupower exits - do you need this free?
Quoted 22 lines
Suggested-by Jun Zhan <[email protected]>Signed-off-by Cryolitia PukNgae <[email protected]>--- tools/power/cpupower/utils/helpers/misc.c | 4 ++++ 1 file changed, 4 insertions(+)tools/power/cpupower/utils/helpers/misc.c +2
-0@@ -213,6 +213,8 @@ void print_online_cpus(void)bitmask_displaylist (online_cpus_str, str_len, online_cpus);printf (_ ("Following CPUs are online:\n%s\n" ), online_cpus_str); } + +free (online_cpus_str); }/* print_offline_cpus
tools/power/cpupower/utils/helpers/misc.c void print_offline_cpus(void) · line 241
Quoted 8 lines
tools/power/cpupower/utils/helpers/misc.c +2
-0@@ -232,6 +234,8 @@ void print_offline_cpus(void)printf (_ ("Following CPUs are offline:\n%s\n" ), offline_cpus_str);printf (_ ("cpupower set operation was not performed on them\n" )); } + +free (offline_cpus_str); }/*
thanks,
-- Shuah