linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf tools: address 2 parse event memory leaks
@ 2019-11-09  7:58 Ian Rogers
  2019-11-11 14:13 ` Arnaldo Carvalho de Melo
  2019-11-15  7:40 ` [tip: perf/core] perf parse: Use YYABORT to clear stack after failure, plugging leaks tip-bot2 for Ian Rogers
  0 siblings, 2 replies; 3+ messages in thread
From: Ian Rogers @ 2019-11-09  7:58 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Andi Kleen, linux-kernel
  Cc: Stephane Eranian, Ian Rogers

Using return rather than YYABORT means that the stack isn't cleared up
following a failure. The change to YYABORT means the return value is 1
rather than -1, but the callers just check for a result of 0 (success).
Add missing free of a list when an error occurs in event_pmu.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/util/parse-events.y | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index 4cac830015be..e2eea4e601b4 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -284,6 +284,7 @@ PE_NAME opt_pmu_config
 	do {						\
 		parse_events_terms__delete($2);		\
 		parse_events_terms__delete(orig_terms);	\
+		free(list);				\
 		free($1);				\
 		free(pattern);				\
 		YYABORT;				\
@@ -550,7 +551,7 @@ tracepoint_name opt_event_config
 	free($1.event);
 	if (err) {
 		free(list);
-		return -1;
+		YYABORT;
 	}
 	$$ = list;
 }
-- 
2.24.0.432.g9d3f5f5b63-goog


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

* Re: [PATCH] perf tools: address 2 parse event memory leaks
  2019-11-09  7:58 [PATCH] perf tools: address 2 parse event memory leaks Ian Rogers
@ 2019-11-11 14:13 ` Arnaldo Carvalho de Melo
  2019-11-15  7:40 ` [tip: perf/core] perf parse: Use YYABORT to clear stack after failure, plugging leaks tip-bot2 for Ian Rogers
  1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-11-11 14:13 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Andi Kleen, linux-kernel,
	Stephane Eranian

Em Fri, Nov 08, 2019 at 11:58:40PM -0800, Ian Rogers escreveu:
> Using return rather than YYABORT means that the stack isn't cleared up
> following a failure. The change to YYABORT means the return value is 1
> rather than -1, but the callers just check for a result of 0 (success).
> Add missing free of a list when an error occurs in event_pmu.

Thanks, applied.

- Arnaldo
 
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
>  tools/perf/util/parse-events.y | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
> index 4cac830015be..e2eea4e601b4 100644
> --- a/tools/perf/util/parse-events.y
> +++ b/tools/perf/util/parse-events.y
> @@ -284,6 +284,7 @@ PE_NAME opt_pmu_config
>  	do {						\
>  		parse_events_terms__delete($2);		\
>  		parse_events_terms__delete(orig_terms);	\
> +		free(list);				\
>  		free($1);				\
>  		free(pattern);				\
>  		YYABORT;				\
> @@ -550,7 +551,7 @@ tracepoint_name opt_event_config
>  	free($1.event);
>  	if (err) {
>  		free(list);
> -		return -1;
> +		YYABORT;
>  	}
>  	$$ = list;
>  }
> -- 
> 2.24.0.432.g9d3f5f5b63-goog

-- 

- Arnaldo

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

* [tip: perf/core] perf parse: Use YYABORT to clear stack after failure, plugging leaks
  2019-11-09  7:58 [PATCH] perf tools: address 2 parse event memory leaks Ian Rogers
  2019-11-11 14:13 ` Arnaldo Carvalho de Melo
@ 2019-11-15  7:40 ` tip-bot2 for Ian Rogers
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Ian Rogers @ 2019-11-15  7:40 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Ian Rogers, Alexander Shishkin, Andi Kleen, Jiri Olsa,
	Mark Rutland, Namhyung Kim, Peter Zijlstra, Stephane Eranian,
	Arnaldo Carvalho de Melo, Ingo Molnar, Borislav Petkov,
	linux-kernel

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     e1e9b78d3957a267346a86c8f2c433f6a332af65
Gitweb:        https://git.kernel.org/tip/e1e9b78d3957a267346a86c8f2c433f6a332af65
Author:        Ian Rogers <irogers@google.com>
AuthorDate:    Fri, 08 Nov 2019 23:58:40 -08:00
Committer:     Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Tue, 12 Nov 2019 08:34:16 -03:00

perf parse: Use YYABORT to clear stack after failure, plugging leaks

Using return rather than YYABORT means that the stack isn't cleared up
following a failure. The change to YYABORT means the return value is 1
rather than -1, but the callers just check for a result of 0 (success).
Add missing free of a list when an error occurs in event_pmu.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20191109075840.181231-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/parse-events.y | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index 4cac830..e2eea4e 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -284,6 +284,7 @@ PE_NAME opt_pmu_config
 	do {						\
 		parse_events_terms__delete($2);		\
 		parse_events_terms__delete(orig_terms);	\
+		free(list);				\
 		free($1);				\
 		free(pattern);				\
 		YYABORT;				\
@@ -550,7 +551,7 @@ tracepoint_name opt_event_config
 	free($1.event);
 	if (err) {
 		free(list);
-		return -1;
+		YYABORT;
 	}
 	$$ = list;
 }

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

end of thread, other threads:[~2019-11-15  7:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-09  7:58 [PATCH] perf tools: address 2 parse event memory leaks Ian Rogers
2019-11-11 14:13 ` Arnaldo Carvalho de Melo
2019-11-15  7:40 ` [tip: perf/core] perf parse: Use YYABORT to clear stack after failure, plugging leaks tip-bot2 for Ian Rogers

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).