* [PATCH] perf pmu: Fix a potential memory leak in perf_pmu__lookup()
@ 2023-08-26 21:32 Christophe JAILLET
2024-02-25 15:42 ` Christophe JAILLET
2024-02-27 17:26 ` Namhyung Kim
0 siblings, 2 replies; 4+ messages in thread
From: Christophe JAILLET @ 2023-08-26 21:32 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
Ian Rogers, Adrian Hunter
Cc: linux-kernel, kernel-janitors, Christophe JAILLET,
Arnaldo Carvalho de Melo, linux-perf-users
The commit in Fixes has reordered some code, but missed an error handling
path.
'goto err' now, in order to avoid a memory leak in case of error.
Fixes: f63a536f03a2 ("perf pmu: Merge JSON events with sysfs at load time")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
tools/perf/util/pmu.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index bb2ca29cd7bd..8dfce84ad9fe 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -1018,10 +1018,9 @@ struct perf_pmu *perf_pmu__lookup(struct list_head *pmus, int dirfd, const char
* type value and format definitions. Load both right
* now.
*/
- if (pmu_format(pmu, dirfd, name)) {
- free(pmu);
- return NULL;
- }
+ if (pmu_format(pmu, dirfd, name))
+ goto err;
+
pmu->is_core = is_pmu_core(name);
pmu->cpus = pmu_cpumask(dirfd, name, pmu->is_core);
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] perf pmu: Fix a potential memory leak in perf_pmu__lookup()
2023-08-26 21:32 [PATCH] perf pmu: Fix a potential memory leak in perf_pmu__lookup() Christophe JAILLET
@ 2024-02-25 15:42 ` Christophe JAILLET
2024-02-25 17:44 ` Ian Rogers
2024-02-27 17:26 ` Namhyung Kim
1 sibling, 1 reply; 4+ messages in thread
From: Christophe JAILLET @ 2024-02-25 15:42 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
Ian Rogers, Adrian Hunter
Cc: linux-kernel, kernel-janitors, Arnaldo Carvalho de Melo,
linux-perf-users
Le 26/08/2023 à 23:32, Christophe JAILLET a écrit :
> The commit in Fixes has reordered some code, but missed an error handling
> path.
>
> 'goto err' now, in order to avoid a memory leak in case of error.
>
> Fixes: f63a536f03a2 ("perf pmu: Merge JSON events with sysfs at load time")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
Hi,
polite reminder.
CJ
> tools/perf/util/pmu.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
> index bb2ca29cd7bd..8dfce84ad9fe 100644
> --- a/tools/perf/util/pmu.c
> +++ b/tools/perf/util/pmu.c
> @@ -1018,10 +1018,9 @@ struct perf_pmu *perf_pmu__lookup(struct list_head *pmus, int dirfd, const char
> * type value and format definitions. Load both right
> * now.
> */
> - if (pmu_format(pmu, dirfd, name)) {
> - free(pmu);
> - return NULL;
> - }
> + if (pmu_format(pmu, dirfd, name))
> + goto err;
> +
> pmu->is_core = is_pmu_core(name);
> pmu->cpus = pmu_cpumask(dirfd, name, pmu->is_core);
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] perf pmu: Fix a potential memory leak in perf_pmu__lookup()
2024-02-25 15:42 ` Christophe JAILLET
@ 2024-02-25 17:44 ` Ian Rogers
0 siblings, 0 replies; 4+ messages in thread
From: Ian Rogers @ 2024-02-25 17:44 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
Adrian Hunter, linux-kernel, kernel-janitors,
Arnaldo Carvalho de Melo, linux-perf-users
On Sun, Feb 25, 2024 at 7:42 AM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> Le 26/08/2023 à 23:32, Christophe JAILLET a écrit :
> > The commit in Fixes has reordered some code, but missed an error handling
> > path.
> >
> > 'goto err' now, in order to avoid a memory leak in case of error.
> >
> > Fixes: f63a536f03a2 ("perf pmu: Merge JSON events with sysfs at load time")
> > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > ---
>
> Hi,
>
> polite reminder.
Apologies for the delay.
Reviewed-by: Ian Rogers <irogers@google.com>
Thanks,
Ian
> CJ
>
>
> > tools/perf/util/pmu.c | 7 +++----
> > 1 file changed, 3 insertions(+), 4 deletions(-)
> >
> > diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
> > index bb2ca29cd7bd..8dfce84ad9fe 100644
> > --- a/tools/perf/util/pmu.c
> > +++ b/tools/perf/util/pmu.c
> > @@ -1018,10 +1018,9 @@ struct perf_pmu *perf_pmu__lookup(struct list_head *pmus, int dirfd, const char
> > * type value and format definitions. Load both right
> > * now.
> > */
> > - if (pmu_format(pmu, dirfd, name)) {
> > - free(pmu);
> > - return NULL;
> > - }
> > + if (pmu_format(pmu, dirfd, name))
> > + goto err;
> > +
> > pmu->is_core = is_pmu_core(name);
> > pmu->cpus = pmu_cpumask(dirfd, name, pmu->is_core);
> >
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] perf pmu: Fix a potential memory leak in perf_pmu__lookup()
2023-08-26 21:32 [PATCH] perf pmu: Fix a potential memory leak in perf_pmu__lookup() Christophe JAILLET
2024-02-25 15:42 ` Christophe JAILLET
@ 2024-02-27 17:26 ` Namhyung Kim
1 sibling, 0 replies; 4+ messages in thread
From: Namhyung Kim @ 2024-02-27 17:26 UTC (permalink / raw)
To: Christophe JAILLET, Mark Rutland, Arnaldo Carvalho de Melo,
Jiri Olsa, Adrian Hunter, Alexander Shishkin, Peter Zijlstra,
Ingo Molnar, Ian Rogers
Cc: linux-perf-users, linux-kernel, kernel-janitors,
Arnaldo Carvalho de Melo
On Sat, 26 Aug 2023 23:32:45 +0200, Christophe JAILLET wrote:
> The commit in Fixes has reordered some code, but missed an error handling
> path.
>
> 'goto err' now, in order to avoid a memory leak in case of error.
>
>
Applied to perf-tools-next, thanks!
Best regards,
--
Namhyung Kim <namhyung@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-02-27 17:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-26 21:32 [PATCH] perf pmu: Fix a potential memory leak in perf_pmu__lookup() Christophe JAILLET
2024-02-25 15:42 ` Christophe JAILLET
2024-02-25 17:44 ` Ian Rogers
2024-02-27 17:26 ` Namhyung Kim
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).