mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] cpupower: Fixing memory leaks
@ 2024-11-21 13:32 liujing
  2024-11-22 18:02 ` Shuah Khan
  0 siblings, 1 reply; 2+ messages in thread
From: liujing @ 2024-11-21 13:32 UTC (permalink / raw)
  To: trenn, shuah, jwyatt, jkacur; +Cc: linux-pm, linux-kernel, liujing

If execlp fails, page memory is not freed, so fix it.

Signed-off-by: liujing <liujing@cmss.chinamobile.com>

diff --git a/tools/power/cpupower/utils/cpupower.c b/tools/power/cpupower/utils/cpupower.c
index 9ec973165af1..36d486199630 100644
--- a/tools/power/cpupower/utils/cpupower.c
+++ b/tools/power/cpupower/utils/cpupower.c
@@ -98,7 +98,7 @@ static int print_man_page(const char *subpage)
 	}
 
 	execlp("man", "man", page, NULL);
-
+	free(page);
 	/* should not be reached */
 	return -EINVAL;
 }
-- 
2.27.0




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] cpupower: Fixing memory leaks
  2024-11-21 13:32 [PATCH] cpupower: Fixing memory leaks liujing
@ 2024-11-22 18:02 ` Shuah Khan
  0 siblings, 0 replies; 2+ messages in thread
From: Shuah Khan @ 2024-11-22 18:02 UTC (permalink / raw)
  To: liujing, trenn, shuah, jwyatt, jkacur; +Cc: linux-pm, linux-kernel, Shuah Khan

On 11/21/24 06:32, liujing wrote:
> If execlp fails, page memory is not freed, so fix it.

How did you find the problem?

> 
> Signed-off-by: liujing <liujing@cmss.chinamobile.com>
> 
> diff --git a/tools/power/cpupower/utils/cpupower.c b/tools/power/cpupower/utils/cpupower.c
> index 9ec973165af1..36d486199630 100644
> --- a/tools/power/cpupower/utils/cpupower.c
> +++ b/tools/power/cpupower/utils/cpupower.c
> @@ -98,7 +98,7 @@ static int print_man_page(const char *subpage)
>   	}
>   
>   	execlp("man", "man", page, NULL);
> -
> +	free(page);

The memory gets free'ed when process exits. Why do you need this?
  
  
>   	/* should not be reached */
>   	return -EINVAL;
>   }

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-11-22 18:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-21 13:32 [PATCH] cpupower: Fixing memory leaks liujing
2024-11-22 18:02 ` Shuah Khan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®