* [PATCH] perf c2c: fix memory leak in build_cl_output()
@ 2019-10-15 2:54 Yunfeng Ye
2019-10-15 8:47 ` Jiri Olsa
2019-10-21 6:26 ` [tip: perf/urgent] perf c2c: Fix " tip-bot2 for Yunfeng Ye
0 siblings, 2 replies; 4+ messages in thread
From: Yunfeng Ye @ 2019-10-15 2:54 UTC (permalink / raw)
To: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa,
namhyung
Cc: linux-kernel, hushiyuan, linfeilong
There is a memory leak problem in the failure paths of
build_cl_output(), so fix it.
Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
---
tools/perf/builtin-c2c.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index 3542b6a..e69f449 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -2635,6 +2635,7 @@ static int build_cl_output(char *cl_sort, bool no_source)
bool add_sym = false;
bool add_dso = false;
bool add_src = false;
+ int ret = 0;
if (!buf)
return -ENOMEM;
@@ -2653,7 +2654,8 @@ static int build_cl_output(char *cl_sort, bool no_source)
add_dso = true;
} else if (strcmp(tok, "offset")) {
pr_err("unrecognized sort token: %s\n", tok);
- return -EINVAL;
+ ret = -EINVAL;
+ goto err;
}
}
@@ -2676,13 +2678,15 @@ static int build_cl_output(char *cl_sort, bool no_source)
add_sym ? "symbol," : "",
add_dso ? "dso," : "",
add_src ? "cl_srcline," : "",
- "node") < 0)
- return -ENOMEM;
+ "node") < 0) {
+ ret = -ENOMEM;
+ goto err;
+ }
c2c.show_src = add_src;
-
+err:
free(buf);
- return 0;
+ return ret;
}
static int setup_coalesce(const char *coalesce, bool no_source)
--
2.7.4.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] perf c2c: fix memory leak in build_cl_output()
2019-10-15 2:54 [PATCH] perf c2c: fix memory leak in build_cl_output() Yunfeng Ye
@ 2019-10-15 8:47 ` Jiri Olsa
2019-10-15 15:08 ` Arnaldo Carvalho de Melo
2019-10-21 6:26 ` [tip: perf/urgent] perf c2c: Fix " tip-bot2 for Yunfeng Ye
1 sibling, 1 reply; 4+ messages in thread
From: Jiri Olsa @ 2019-10-15 8:47 UTC (permalink / raw)
To: Yunfeng Ye
Cc: peterz, mingo, acme, mark.rutland, alexander.shishkin, namhyung,
linux-kernel, hushiyuan, linfeilong
On Tue, Oct 15, 2019 at 10:54:14AM +0800, Yunfeng Ye wrote:
> There is a memory leak problem in the failure paths of
> build_cl_output(), so fix it.
>
> Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
thanks,
jirka
> ---
> tools/perf/builtin-c2c.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
> index 3542b6a..e69f449 100644
> --- a/tools/perf/builtin-c2c.c
> +++ b/tools/perf/builtin-c2c.c
> @@ -2635,6 +2635,7 @@ static int build_cl_output(char *cl_sort, bool no_source)
> bool add_sym = false;
> bool add_dso = false;
> bool add_src = false;
> + int ret = 0;
>
> if (!buf)
> return -ENOMEM;
> @@ -2653,7 +2654,8 @@ static int build_cl_output(char *cl_sort, bool no_source)
> add_dso = true;
> } else if (strcmp(tok, "offset")) {
> pr_err("unrecognized sort token: %s\n", tok);
> - return -EINVAL;
> + ret = -EINVAL;
> + goto err;
> }
> }
>
> @@ -2676,13 +2678,15 @@ static int build_cl_output(char *cl_sort, bool no_source)
> add_sym ? "symbol," : "",
> add_dso ? "dso," : "",
> add_src ? "cl_srcline," : "",
> - "node") < 0)
> - return -ENOMEM;
> + "node") < 0) {
> + ret = -ENOMEM;
> + goto err;
> + }
>
> c2c.show_src = add_src;
> -
> +err:
> free(buf);
> - return 0;
> + return ret;
> }
>
> static int setup_coalesce(const char *coalesce, bool no_source)
> --
> 2.7.4.3
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] perf c2c: fix memory leak in build_cl_output()
2019-10-15 8:47 ` Jiri Olsa
@ 2019-10-15 15:08 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-10-15 15:08 UTC (permalink / raw)
To: Jiri Olsa
Cc: Yunfeng Ye, peterz, mingo, mark.rutland, alexander.shishkin,
namhyung, linux-kernel, hushiyuan, linfeilong
Em Tue, Oct 15, 2019 at 10:47:53AM +0200, Jiri Olsa escreveu:
> On Tue, Oct 15, 2019 at 10:54:14AM +0800, Yunfeng Ye wrote:
> > There is a memory leak problem in the failure paths of
> > build_cl_output(), so fix it.
> >
> > Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
>
> Acked-by: Jiri Olsa <jolsa@kernel.org>
Thanks, applied to perf/urgent.
- Arnaldo
> thanks,
> jirka
>
> > ---
> > tools/perf/builtin-c2c.c | 14 +++++++++-----
> > 1 file changed, 9 insertions(+), 5 deletions(-)
> >
> > diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
> > index 3542b6a..e69f449 100644
> > --- a/tools/perf/builtin-c2c.c
> > +++ b/tools/perf/builtin-c2c.c
> > @@ -2635,6 +2635,7 @@ static int build_cl_output(char *cl_sort, bool no_source)
> > bool add_sym = false;
> > bool add_dso = false;
> > bool add_src = false;
> > + int ret = 0;
> >
> > if (!buf)
> > return -ENOMEM;
> > @@ -2653,7 +2654,8 @@ static int build_cl_output(char *cl_sort, bool no_source)
> > add_dso = true;
> > } else if (strcmp(tok, "offset")) {
> > pr_err("unrecognized sort token: %s\n", tok);
> > - return -EINVAL;
> > + ret = -EINVAL;
> > + goto err;
> > }
> > }
> >
> > @@ -2676,13 +2678,15 @@ static int build_cl_output(char *cl_sort, bool no_source)
> > add_sym ? "symbol," : "",
> > add_dso ? "dso," : "",
> > add_src ? "cl_srcline," : "",
> > - "node") < 0)
> > - return -ENOMEM;
> > + "node") < 0) {
> > + ret = -ENOMEM;
> > + goto err;
> > + }
> >
> > c2c.show_src = add_src;
> > -
> > +err:
> > free(buf);
> > - return 0;
> > + return ret;
> > }
> >
> > static int setup_coalesce(const char *coalesce, bool no_source)
> > --
> > 2.7.4.3
> >
--
- Arnaldo
^ permalink raw reply [flat|nested] 4+ messages in thread
* [tip: perf/urgent] perf c2c: Fix memory leak in build_cl_output()
2019-10-15 2:54 [PATCH] perf c2c: fix memory leak in build_cl_output() Yunfeng Ye
2019-10-15 8:47 ` Jiri Olsa
@ 2019-10-21 6:26 ` tip-bot2 for Yunfeng Ye
1 sibling, 0 replies; 4+ messages in thread
From: tip-bot2 for Yunfeng Ye @ 2019-10-21 6:26 UTC (permalink / raw)
To: linux-tip-commits
Cc: Yunfeng Ye, Jiri Olsa, Alexander Shishkin, Feilong Lin,
Hu Shiyuan, Mark Rutland, Namhyung Kim, Peter Zijlstra,
Arnaldo Carvalho de Melo, Ingo Molnar, Borislav Petkov,
linux-kernel
The following commit has been merged into the perf/urgent branch of tip:
Commit-ID: ae199c580da1754a2b051321eeb76d6dacd8707b
Gitweb: https://git.kernel.org/tip/ae199c580da1754a2b051321eeb76d6dacd8707b
Author: Yunfeng Ye <yeyunfeng@huawei.com>
AuthorDate: Tue, 15 Oct 2019 10:54:14 +08:00
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Tue, 15 Oct 2019 12:08:13 -03:00
perf c2c: Fix memory leak in build_cl_output()
There is a memory leak problem in the failure paths of
build_cl_output(), so fix it.
Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Feilong Lin <linfeilong@huawei.com>
Cc: Hu Shiyuan <hushiyuan@huawei.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/4d3c0178-5482-c313-98e1-f82090d2d456@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-c2c.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index 3542b6a..e69f449 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -2635,6 +2635,7 @@ static int build_cl_output(char *cl_sort, bool no_source)
bool add_sym = false;
bool add_dso = false;
bool add_src = false;
+ int ret = 0;
if (!buf)
return -ENOMEM;
@@ -2653,7 +2654,8 @@ static int build_cl_output(char *cl_sort, bool no_source)
add_dso = true;
} else if (strcmp(tok, "offset")) {
pr_err("unrecognized sort token: %s\n", tok);
- return -EINVAL;
+ ret = -EINVAL;
+ goto err;
}
}
@@ -2676,13 +2678,15 @@ static int build_cl_output(char *cl_sort, bool no_source)
add_sym ? "symbol," : "",
add_dso ? "dso," : "",
add_src ? "cl_srcline," : "",
- "node") < 0)
- return -ENOMEM;
+ "node") < 0) {
+ ret = -ENOMEM;
+ goto err;
+ }
c2c.show_src = add_src;
-
+err:
free(buf);
- return 0;
+ return ret;
}
static int setup_coalesce(const char *coalesce, bool no_source)
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-10-21 6:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-15 2:54 [PATCH] perf c2c: fix memory leak in build_cl_output() Yunfeng Ye
2019-10-15 8:47 ` Jiri Olsa
2019-10-15 15:08 ` Arnaldo Carvalho de Melo
2019-10-21 6:26 ` [tip: perf/urgent] perf c2c: Fix " tip-bot2 for Yunfeng Ye
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.