Re: [PATCH 20/20] perf util/probe-file: delete namelist on error in del_events

From: Arnaldo Carvalho de Melo
Date: Thu Jul 15 2021 - 16:41:34 EST


Em Thu, Jul 15, 2021 at 06:07:25PM +0200, Riccardo Mancini escreveu:
> ASan reports some memory leaks when running the perf test
> "42: BPF filter".
> This second leak is caused by a strlist not being dellocated on error
> inside probe_file__del_events.
>
> This patch adds a goto label before the deallocation and makes the error
> path jump to it.

Fixes: e7895e422e4da63d ("perf probe: Split del_perf_probe_events()")

Thanks, applied.

- Arnaldo


> Signed-off-by: Riccardo Mancini <rickyman7@xxxxxxxxx>
> ---
> tools/perf/util/probe-file.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
> index f9a6cbcd641501b8..3d50de3217d50ae1 100644
> --- a/tools/perf/util/probe-file.c
> +++ b/tools/perf/util/probe-file.c
> @@ -377,11 +377,11 @@ int probe_file__del_events(int fd, struct strfilter *filter)
>
> ret = probe_file__get_events(fd, filter, namelist);
> if (ret < 0)
> - return ret;
> + goto out;
>
> ret = probe_file__del_strlist(fd, namelist);
> +out:
> strlist__delete(namelist);
> -
> return ret;
> }
>
> --
> 2.31.1
>

--

- Arnaldo