linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf script: Fix memory leaks in list_scripts()
@ 2019-04-08 16:27 Gustavo A. R. Silva
  2019-04-22 15:14 ` Gustavo A. R. Silva
       [not found] ` <156689437793.24518.1210962260082729908.tip-bot2@tip-bot2>
  0 siblings, 2 replies; 7+ messages in thread
From: Gustavo A. R. Silva @ 2019-04-08 16:27 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Alexander Shishkin, Jiri Olsa, Namhyung Kim, Andi Kleen
  Cc: linux-kernel, Gustavo A. R. Silva

In case memory resources for *buf* and *paths* were allocated,
jump to *out* and release them before return.

Addresses-Coverity-ID: 1444328 ("Resource leak")
Fixes: 6f3da20e151f ("perf report: Support builtin perf script in scripts menu")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 tools/perf/ui/browsers/scripts.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/perf/ui/browsers/scripts.c b/tools/perf/ui/browsers/scripts.c
index 27cf3ab88d13..f4edb18f67ec 100644
--- a/tools/perf/ui/browsers/scripts.c
+++ b/tools/perf/ui/browsers/scripts.c
@@ -131,8 +131,10 @@ static int list_scripts(char *script_name, bool *custom,
 		int key = ui_browser__input_window("perf script command",
 				"Enter perf script command line (without perf script prefix)",
 				script_args, "", 0);
-		if (key != K_ENTER)
-			return -1;
+		if (key != K_ENTER) {
+			ret = -1;
+			goto out;
+		}
 		sprintf(script_name, "%s script %s", perf, script_args);
 	} else if (choice < num + max_std) {
 		strcpy(script_name, paths[choice]);
-- 
2.21.0


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

* Re: [PATCH] perf script: Fix memory leaks in list_scripts()
  2019-04-08 16:27 [PATCH] perf script: Fix memory leaks in list_scripts() Gustavo A. R. Silva
@ 2019-04-22 15:14 ` Gustavo A. R. Silva
  2019-08-26  4:06   ` Gustavo A. R. Silva
       [not found] ` <156689437793.24518.1210962260082729908.tip-bot2@tip-bot2>
  1 sibling, 1 reply; 7+ messages in thread
From: Gustavo A. R. Silva @ 2019-04-22 15:14 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Alexander Shishkin, Jiri Olsa, Namhyung Kim, Andi Kleen
  Cc: linux-kernel

Hi all,

Friendly ping:

Who can take this?

Thanks

On 4/8/19 11:27 AM, Gustavo A. R. Silva wrote:
> In case memory resources for *buf* and *paths* were allocated,
> jump to *out* and release them before return.
> 
> Addresses-Coverity-ID: 1444328 ("Resource leak")
> Fixes: 6f3da20e151f ("perf report: Support builtin perf script in scripts menu")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
>  tools/perf/ui/browsers/scripts.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/ui/browsers/scripts.c b/tools/perf/ui/browsers/scripts.c
> index 27cf3ab88d13..f4edb18f67ec 100644
> --- a/tools/perf/ui/browsers/scripts.c
> +++ b/tools/perf/ui/browsers/scripts.c
> @@ -131,8 +131,10 @@ static int list_scripts(char *script_name, bool *custom,
>  		int key = ui_browser__input_window("perf script command",
>  				"Enter perf script command line (without perf script prefix)",
>  				script_args, "", 0);
> -		if (key != K_ENTER)
> -			return -1;
> +		if (key != K_ENTER) {
> +			ret = -1;
> +			goto out;
> +		}
>  		sprintf(script_name, "%s script %s", perf, script_args);
>  	} else if (choice < num + max_std) {
>  		strcpy(script_name, paths[choice]);
> 

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

* Re: [PATCH] perf script: Fix memory leaks in list_scripts()
  2019-04-22 15:14 ` Gustavo A. R. Silva
@ 2019-08-26  4:06   ` Gustavo A. R. Silva
  2019-08-26 14:07     ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 7+ messages in thread
From: Gustavo A. R. Silva @ 2019-08-26  4:06 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Alexander Shishkin, Jiri Olsa, Namhyung Kim, Andi Kleen
  Cc: linux-kernel

Hi all,

Friendly ping (second one after 4 months):

Who can take this?

Thanks
--
Gustavo

On 4/22/19 10:14 AM, Gustavo A. R. Silva wrote:
> Hi all,
> 
> Friendly ping:
> 
> Who can take this?
> 
> Thanks
> 
> On 4/8/19 11:27 AM, Gustavo A. R. Silva wrote:
>> In case memory resources for *buf* and *paths* were allocated,
>> jump to *out* and release them before return.
>>
>> Addresses-Coverity-ID: 1444328 ("Resource leak")
>> Fixes: 6f3da20e151f ("perf report: Support builtin perf script in scripts menu")
>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>> ---
>>  tools/perf/ui/browsers/scripts.c | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/perf/ui/browsers/scripts.c b/tools/perf/ui/browsers/scripts.c
>> index 27cf3ab88d13..f4edb18f67ec 100644
>> --- a/tools/perf/ui/browsers/scripts.c
>> +++ b/tools/perf/ui/browsers/scripts.c
>> @@ -131,8 +131,10 @@ static int list_scripts(char *script_name, bool *custom,
>>  		int key = ui_browser__input_window("perf script command",
>>  				"Enter perf script command line (without perf script prefix)",
>>  				script_args, "", 0);
>> -		if (key != K_ENTER)
>> -			return -1;
>> +		if (key != K_ENTER) {
>> +			ret = -1;
>> +			goto out;
>> +		}
>>  		sprintf(script_name, "%s script %s", perf, script_args);
>>  	} else if (choice < num + max_std) {
>>  		strcpy(script_name, paths[choice]);
>>

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

* Re: [PATCH] perf script: Fix memory leaks in list_scripts()
  2019-08-26  4:06   ` Gustavo A. R. Silva
@ 2019-08-26 14:07     ` Arnaldo Carvalho de Melo
  2019-08-26 15:59       ` Gustavo A. R. Silva
  0 siblings, 1 reply; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-08-26 14:07 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Peter Zijlstra, Ingo Molnar, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, Andi Kleen, linux-kernel

Em Sun, Aug 25, 2019 at 11:06:25PM -0500, Gustavo A. R. Silva escreveu:
> Hi all,
> 
> Friendly ping (second one after 4 months):
> 
> Who can take this?

Sorry for the delay, finally applied, thanks!

- Arnaldo
 
> Thanks
> --
> Gustavo
> 
> On 4/22/19 10:14 AM, Gustavo A. R. Silva wrote:
> > Hi all,
> > 
> > Friendly ping:
> > 
> > Who can take this?
> > 
> > Thanks
> > 
> > On 4/8/19 11:27 AM, Gustavo A. R. Silva wrote:
> >> In case memory resources for *buf* and *paths* were allocated,
> >> jump to *out* and release them before return.
> >>
> >> Addresses-Coverity-ID: 1444328 ("Resource leak")
> >> Fixes: 6f3da20e151f ("perf report: Support builtin perf script in scripts menu")
> >> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> >> ---
> >>  tools/perf/ui/browsers/scripts.c | 6 ++++--
> >>  1 file changed, 4 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/tools/perf/ui/browsers/scripts.c b/tools/perf/ui/browsers/scripts.c
> >> index 27cf3ab88d13..f4edb18f67ec 100644
> >> --- a/tools/perf/ui/browsers/scripts.c
> >> +++ b/tools/perf/ui/browsers/scripts.c
> >> @@ -131,8 +131,10 @@ static int list_scripts(char *script_name, bool *custom,
> >>  		int key = ui_browser__input_window("perf script command",
> >>  				"Enter perf script command line (without perf script prefix)",
> >>  				script_args, "", 0);
> >> -		if (key != K_ENTER)
> >> -			return -1;
> >> +		if (key != K_ENTER) {
> >> +			ret = -1;
> >> +			goto out;
> >> +		}
> >>  		sprintf(script_name, "%s script %s", perf, script_args);
> >>  	} else if (choice < num + max_std) {
> >>  		strcpy(script_name, paths[choice]);
> >>

-- 

- Arnaldo

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

* Re: [PATCH] perf script: Fix memory leaks in list_scripts()
  2019-08-26 14:07     ` Arnaldo Carvalho de Melo
@ 2019-08-26 15:59       ` Gustavo A. R. Silva
  0 siblings, 0 replies; 7+ messages in thread
From: Gustavo A. R. Silva @ 2019-08-26 15:59 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, Andi Kleen, linux-kernel



On 8/26/19 9:07 AM, Arnaldo Carvalho de Melo wrote:
> Em Sun, Aug 25, 2019 at 11:06:25PM -0500, Gustavo A. R. Silva escreveu:
>> Hi all,
>>
>> Friendly ping (second one after 4 months):
>>
>> Who can take this?
> 
> Sorry for the delay, finally applied, thanks!
> 

Awesome. :)

Thanks, Arnaldo.
--
Gustavo

> - Arnaldo
>  
>> Thanks
>> --
>> Gustavo
>>
>> On 4/22/19 10:14 AM, Gustavo A. R. Silva wrote:
>>> Hi all,
>>>
>>> Friendly ping:
>>>
>>> Who can take this?
>>>
>>> Thanks
>>>
>>> On 4/8/19 11:27 AM, Gustavo A. R. Silva wrote:
>>>> In case memory resources for *buf* and *paths* were allocated,
>>>> jump to *out* and release them before return.
>>>>
>>>> Addresses-Coverity-ID: 1444328 ("Resource leak")
>>>> Fixes: 6f3da20e151f ("perf report: Support builtin perf script in scripts menu")
>>>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>>>> ---
>>>>  tools/perf/ui/browsers/scripts.c | 6 ++++--
>>>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/tools/perf/ui/browsers/scripts.c b/tools/perf/ui/browsers/scripts.c
>>>> index 27cf3ab88d13..f4edb18f67ec 100644
>>>> --- a/tools/perf/ui/browsers/scripts.c
>>>> +++ b/tools/perf/ui/browsers/scripts.c
>>>> @@ -131,8 +131,10 @@ static int list_scripts(char *script_name, bool *custom,
>>>>  		int key = ui_browser__input_window("perf script command",
>>>>  				"Enter perf script command line (without perf script prefix)",
>>>>  				script_args, "", 0);
>>>> -		if (key != K_ENTER)
>>>> -			return -1;
>>>> +		if (key != K_ENTER) {
>>>> +			ret = -1;
>>>> +			goto out;
>>>> +		}
>>>>  		sprintf(script_name, "%s script %s", perf, script_args);
>>>>  	} else if (choice < num + max_std) {
>>>>  		strcpy(script_name, paths[choice]);
>>>>
> 

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

* Re: [tip: perf/core] perf script: Fix memory leaks in list_scripts()
       [not found] ` <156689437793.24518.1210962260082729908.tip-bot2@tip-bot2>
@ 2019-08-27 16:12   ` Gustavo A. R. Silva
  2019-08-27 21:45     ` Andi Kleen
  0 siblings, 1 reply; 7+ messages in thread
From: Gustavo A. R. Silva @ 2019-08-27 16:12 UTC (permalink / raw)
  To: linux-kernel, linux-tip-commits
  Cc: Alexander Shishkin, Andi Kleen, Jiri Olsa, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo, Ingo Molnar,
	Borislav Petkov

Hi,

On 8/27/19 3:26 AM, tip-bot2 for Gustavo A. R. Silva wrote:
> The following commit has been merged into the perf/core branch of tip:
> 
> Commit-ID:     3b4acbb92dbda4829e021e5c6d5410658849fa1c
> Gitweb:        https://git.kernel.org/tip/3b4acbb92dbda4829e021e5c6d5410658849fa1c
> Author:        Gustavo A. R. Silva <gustavo@embeddedor.com>
> AuthorDate:    Mon, 08 Apr 2019 11:27:48 -05:00
> Committer:     Arnaldo Carvalho de Melo <acme@redhat.com>
> CommitterDate: Mon, 26 Aug 2019 11:58:30 -03:00
> 
> perf script: Fix memory leaks in list_scripts()
> 
> In case memory resources for *buf* and *paths* were allocated, jump to
> *out* and release them before return.
> 
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

This should be tagged for stable:

Cc: stable@vger.kernel.org

> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> Cc: Andi Kleen <ak@linux.intel.com>
> Cc: Gustavo A. R. Silva <gustavo@embeddedor.com>
> Cc: Jiri Olsa <jolsa@redhat.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Addresses-Coverity-ID: 1444328 ("Resource leak")
> Fixes: 6f3da20e151f ("perf report: Support builtin perf script in scripts menu")
> Link: http://lkml.kernel.org/r/20190408162748.GA21008@embeddedor
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> ---
>  tools/perf/ui/browsers/scripts.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/ui/browsers/scripts.c b/tools/perf/ui/browsers/scripts.c
> index f2fd9f0..50e0c03 100644
> --- a/tools/perf/ui/browsers/scripts.c
> +++ b/tools/perf/ui/browsers/scripts.c
> @@ -133,8 +133,10 @@ static int list_scripts(char *script_name, bool *custom,
>  		int key = ui_browser__input_window("perf script command",
>  				"Enter perf script command line (without perf script prefix)",
>  				script_args, "", 0);
> -		if (key != K_ENTER)
> -			return -1;
> +		if (key != K_ENTER) {
> +			ret = -1;
> +			goto out;
> +		}
>  		sprintf(script_name, "%s script %s", perf, script_args);
>  	} else if (choice < num + max_std) {
>  		strcpy(script_name, paths[choice]);
> 

--
Gustavo

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

* Re: [tip: perf/core] perf script: Fix memory leaks in list_scripts()
  2019-08-27 16:12   ` [tip: perf/core] " Gustavo A. R. Silva
@ 2019-08-27 21:45     ` Andi Kleen
  0 siblings, 0 replies; 7+ messages in thread
From: Andi Kleen @ 2019-08-27 21:45 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: linux-kernel, linux-tip-commits, Alexander Shishkin, Jiri Olsa,
	Namhyung Kim, Peter Zijlstra, Arnaldo Carvalho de Melo,
	Ingo Molnar, Borislav Petkov

> > Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> 
> This should be tagged for stable:
> 
> Cc: stable@vger.kernel.org

It's a theoretical problem (which are explicitely ruled out by stable rules)
because if you ever see user space malloc() returning NULL the system is likely
already randomly killing your processes in OOM, including eventually perf.

I can see the value of shutting up coverity though, but that's not something
that needs to be in stable.

-Andi

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

end of thread, other threads:[~2019-08-27 21:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-08 16:27 [PATCH] perf script: Fix memory leaks in list_scripts() Gustavo A. R. Silva
2019-04-22 15:14 ` Gustavo A. R. Silva
2019-08-26  4:06   ` Gustavo A. R. Silva
2019-08-26 14:07     ` Arnaldo Carvalho de Melo
2019-08-26 15:59       ` Gustavo A. R. Silva
     [not found] ` <156689437793.24518.1210962260082729908.tip-bot2@tip-bot2>
2019-08-27 16:12   ` [tip: perf/core] " Gustavo A. R. Silva
2019-08-27 21:45     ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).