All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] perf util: Fix memory leak in __parse_regs()
@ 2020-07-03  9:33 Zheng Zengkai
  2020-07-03 10:31 ` Jiri Olsa
  0 siblings, 1 reply; 4+ messages in thread
From: Zheng Zengkai @ 2020-07-03  9:33 UTC (permalink / raw)
  To: acme, mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: linux-kernel, huawei.libin, zhengzengkai

when using perf record option '-I' or '--user-regs='
along with argument '?' to list available register names,
memory of variable 'os' allocated by strdup() needs to be released
before __parse_regs() returns, otherwise memory leak will occur.

Fixes: bcc84ec65ad1 ("perf record: Add ability to name registers to record")
Signed-off-by: Zheng Zengkai <zhengzengkai@huawei.com>
---
 tools/perf/util/parse-regs-options.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/parse-regs-options.c b/tools/perf/util/parse-regs-options.c
index e687497b3aac..a4a100425b3a 100644
--- a/tools/perf/util/parse-regs-options.c
+++ b/tools/perf/util/parse-regs-options.c
@@ -54,7 +54,7 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr)
 #endif
 				fputc('\n', stderr);
 				/* just printing available regs */
-				return -1;
+				goto error;
 			}
 #ifdef HAVE_PERF_REGS_SUPPORT
 			for (r = sample_reg_masks; r->name; r++) {
-- 
2.20.1


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

* Re: [PATCH -next] perf util: Fix memory leak in __parse_regs()
  2020-07-03  9:33 [PATCH -next] perf util: Fix memory leak in __parse_regs() Zheng Zengkai
@ 2020-07-03 10:31 ` Jiri Olsa
  2020-11-27  7:45   ` Zheng Zengkai
  0 siblings, 1 reply; 4+ messages in thread
From: Jiri Olsa @ 2020-07-03 10:31 UTC (permalink / raw)
  To: Zheng Zengkai
  Cc: acme, mark.rutland, alexander.shishkin, namhyung, linux-kernel,
	huawei.libin

On Fri, Jul 03, 2020 at 05:33:44PM +0800, Zheng Zengkai wrote:
> when using perf record option '-I' or '--user-regs='
> along with argument '?' to list available register names,
> memory of variable 'os' allocated by strdup() needs to be released
> before __parse_regs() returns, otherwise memory leak will occur.
> 
> Fixes: bcc84ec65ad1 ("perf record: Add ability to name registers to record")
> Signed-off-by: Zheng Zengkai <zhengzengkai@huawei.com>

Acked-by: Jiri Olsa <jolsa@redhat.com>

thanks,
jirka

> ---
>  tools/perf/util/parse-regs-options.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/parse-regs-options.c b/tools/perf/util/parse-regs-options.c
> index e687497b3aac..a4a100425b3a 100644
> --- a/tools/perf/util/parse-regs-options.c
> +++ b/tools/perf/util/parse-regs-options.c
> @@ -54,7 +54,7 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr)
>  #endif
>  				fputc('\n', stderr);
>  				/* just printing available regs */
> -				return -1;
> +				goto error;
>  			}
>  #ifdef HAVE_PERF_REGS_SUPPORT
>  			for (r = sample_reg_masks; r->name; r++) {
> -- 
> 2.20.1
> 


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

* Re: [PATCH -next] perf util: Fix memory leak in __parse_regs()
  2020-07-03 10:31 ` Jiri Olsa
@ 2020-11-27  7:45   ` Zheng Zengkai
  2020-12-07 16:45     ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 4+ messages in thread
From: Zheng Zengkai @ 2020-11-27  7:45 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: acme, mark.rutland, alexander.shishkin, namhyung, linux-kernel,
	huawei.libin

Ping...

> On Fri, Jul 03, 2020 at 05:33:44PM +0800, Zheng Zengkai wrote:
>> when using perf record option '-I' or '--user-regs='
>> along with argument '?' to list available register names,
>> memory of variable 'os' allocated by strdup() needs to be released
>> before __parse_regs() returns, otherwise memory leak will occur.
>>
>> Fixes: bcc84ec65ad1 ("perf record: Add ability to name registers to record")
>> Signed-off-by: Zheng Zengkai <zhengzengkai@huawei.com>
> Acked-by: Jiri Olsa <jolsa@redhat.com>
>
> thanks,
> jirka
>
>> ---
>>   tools/perf/util/parse-regs-options.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/perf/util/parse-regs-options.c b/tools/perf/util/parse-regs-options.c
>> index e687497b3aac..a4a100425b3a 100644
>> --- a/tools/perf/util/parse-regs-options.c
>> +++ b/tools/perf/util/parse-regs-options.c
>> @@ -54,7 +54,7 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr)
>>   #endif
>>   				fputc('\n', stderr);
>>   				/* just printing available regs */
>> -				return -1;
>> +				goto error;
>>   			}
>>   #ifdef HAVE_PERF_REGS_SUPPORT
>>   			for (r = sample_reg_masks; r->name; r++) {
>> -- 
>> 2.20.1
>>
> .
>

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

* Re: [PATCH -next] perf util: Fix memory leak in __parse_regs()
  2020-11-27  7:45   ` Zheng Zengkai
@ 2020-12-07 16:45     ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2020-12-07 16:45 UTC (permalink / raw)
  To: Zheng Zengkai
  Cc: Jiri Olsa, mark.rutland, alexander.shishkin, namhyung,
	linux-kernel, huawei.libin

Em Fri, Nov 27, 2020 at 03:45:40PM +0800, Zheng Zengkai escreveu:
> Ping...

Thanks, applied.

- Arnaldo
 
> > On Fri, Jul 03, 2020 at 05:33:44PM +0800, Zheng Zengkai wrote:
> > > when using perf record option '-I' or '--user-regs='
> > > along with argument '?' to list available register names,
> > > memory of variable 'os' allocated by strdup() needs to be released
> > > before __parse_regs() returns, otherwise memory leak will occur.
> > > 
> > > Fixes: bcc84ec65ad1 ("perf record: Add ability to name registers to record")
> > > Signed-off-by: Zheng Zengkai <zhengzengkai@huawei.com>
> > Acked-by: Jiri Olsa <jolsa@redhat.com>
> > 
> > thanks,
> > jirka
> > 
> > > ---
> > >   tools/perf/util/parse-regs-options.c | 2 +-
> > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/tools/perf/util/parse-regs-options.c b/tools/perf/util/parse-regs-options.c
> > > index e687497b3aac..a4a100425b3a 100644
> > > --- a/tools/perf/util/parse-regs-options.c
> > > +++ b/tools/perf/util/parse-regs-options.c
> > > @@ -54,7 +54,7 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr)
> > >   #endif
> > >   				fputc('\n', stderr);
> > >   				/* just printing available regs */
> > > -				return -1;
> > > +				goto error;
> > >   			}
> > >   #ifdef HAVE_PERF_REGS_SUPPORT
> > >   			for (r = sample_reg_masks; r->name; r++) {
> > > -- 
> > > 2.20.1
> > > 
> > .
> > 

-- 

- Arnaldo

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

end of thread, other threads:[~2020-12-07 16:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-03  9:33 [PATCH -next] perf util: Fix memory leak in __parse_regs() Zheng Zengkai
2020-07-03 10:31 ` Jiri Olsa
2020-11-27  7:45   ` Zheng Zengkai
2020-12-07 16:45     ` Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.