[PATCH v2 1/4] perf stat: Fix affinity memory leaks on error path

Ian Rogers posted 4 patches 1 month, 4 weeks ago
[PATCH v2 1/4] perf stat: Fix affinity memory leaks on error path
Posted by Ian Rogers 1 month, 4 weeks ago
Missed cleanup when an error occurs.

Fixes: 49de179577e7 ("perf stat: No need to setup affinities when starting a workload")
Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/builtin-stat.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 1521b6df2606..3e6b9f216e80 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -827,6 +827,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
 		}
 	}
 	affinity__cleanup(affinity);
+	affinity = NULL;
 
 	evlist__for_each_entry(evsel_list, counter) {
 		if (!counter->supported) {
@@ -965,6 +966,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
 	if (forks)
 		evlist__cancel_workload(evsel_list);
 
+	affinity__cleanup(affinity);
 	return err;
 }
 
-- 
2.46.1.824.gd892dcdcdd-goog
Re: [PATCH v2 1/4] perf stat: Fix affinity memory leaks on error path
Posted by Namhyung Kim 1 month, 3 weeks ago
On Mon, Sep 30, 2024 at 10:23:24PM -0700, Ian Rogers wrote:
> Missed cleanup when an error occurs.
> 
> Fixes: 49de179577e7 ("perf stat: No need to setup affinities when starting a workload")
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
>  tools/perf/builtin-stat.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> index 1521b6df2606..3e6b9f216e80 100644
> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
> @@ -827,6 +827,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
>  		}
>  	}
>  	affinity__cleanup(affinity);
> +	affinity = NULL;
>  
>  	evlist__for_each_entry(evsel_list, counter) {
>  		if (!counter->supported) {
> @@ -965,6 +966,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
>  	if (forks)
>  		evlist__cancel_workload(evsel_list);
>  
> +	affinity__cleanup(affinity);
>  	return err;

Much better now, thanks!
Namhyung


>  }
>  
> -- 
> 2.46.1.824.gd892dcdcdd-goog
>