linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] perf probe: Fix an error handling path in 'parse_perf_probe_command()'
@ 2022-08-06 14:51 Christophe JAILLET
  2022-08-10 13:10 ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2022-08-06 14:51 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Masami Hiramatsu
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET,
	Arnaldo Carvalho de Melo, linux-perf-users

If a memory allocation fail, we should branch to the error handling path in
order to free some resources allocated a few lines above.

Fixes: 15354d546986 ("perf probe: Generate event name with line number")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
---
Change in v2:
 - Synch with latest -next
 - Add A-by tag (see link below, it was old!)

v1:
 https://lore.kernel.org/all/20200315201259.29190-1-christophe.jaillet@wanadoo.fr/
---
 tools/perf/util/probe-event.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 67c12d5303e7..785246ff4179 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -1775,8 +1775,10 @@ int parse_perf_probe_command(const char *cmd, struct perf_probe_event *pev)
 	if (!pev->event && pev->point.function && pev->point.line
 			&& !pev->point.lazy_line && !pev->point.offset) {
 		if (asprintf(&pev->event, "%s_L%d", pev->point.function,
-			pev->point.line) < 0)
-			return -ENOMEM;
+			pev->point.line) < 0) {
+			ret = -ENOMEM;
+			goto out;
+		}
 	}
 
 	/* Copy arguments and ensure return probe has no C argument */
-- 
2.34.1


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

* Re: [PATCH v2] perf probe: Fix an error handling path in 'parse_perf_probe_command()'
  2022-08-06 14:51 [PATCH v2] perf probe: Fix an error handling path in 'parse_perf_probe_command()' Christophe JAILLET
@ 2022-08-10 13:10 ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-08-10 13:10 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Masami Hiramatsu, linux-kernel,
	kernel-janitors, Arnaldo Carvalho de Melo, linux-perf-users

Em Sat, Aug 06, 2022 at 04:51:26PM +0200, Christophe JAILLET escreveu:
> If a memory allocation fail, we should branch to the error handling path in
> order to free some resources allocated a few lines above.
> 
> Fixes: 15354d546986 ("perf probe: Generate event name with line number")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> Acked-by: Masami Hiramatsu <mhiramat@kernel.org>


Thanks, applied.

- Arnaldo


> ---
> Change in v2:
>  - Synch with latest -next
>  - Add A-by tag (see link below, it was old!)
> 
> v1:
>  https://lore.kernel.org/all/20200315201259.29190-1-christophe.jaillet@wanadoo.fr/
> ---
>  tools/perf/util/probe-event.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index 67c12d5303e7..785246ff4179 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -1775,8 +1775,10 @@ int parse_perf_probe_command(const char *cmd, struct perf_probe_event *pev)
>  	if (!pev->event && pev->point.function && pev->point.line
>  			&& !pev->point.lazy_line && !pev->point.offset) {
>  		if (asprintf(&pev->event, "%s_L%d", pev->point.function,
> -			pev->point.line) < 0)
> -			return -ENOMEM;
> +			pev->point.line) < 0) {
> +			ret = -ENOMEM;
> +			goto out;
> +		}
>  	}
>  
>  	/* Copy arguments and ensure return probe has no C argument */
> -- 
> 2.34.1

-- 

- Arnaldo

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

end of thread, other threads:[~2022-08-10 13:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-06 14:51 [PATCH v2] perf probe: Fix an error handling path in 'parse_perf_probe_command()' Christophe JAILLET
2022-08-10 13:10 ` Arnaldo Carvalho de Melo

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