diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c index 4dd52feb1ae63e764f26d92879cf036d25eb195d..b078d54d424557abe83f8eb9a14c9ca29f59a02d 100644 --- a/tools/perf/util/cgroup.c +++ b/tools/perf/util/cgroup.c @@ -135,9 +135,8 @@ static int add_cgroup(struct perf_evlist *evlist, char *str) goto found; n++; } - if (refcount_dec_and_test(&cgrp->refcnt)) - free(cgrp); + cgroup__put(cgrp); return -1; found: counter->cgrp = cgrp; @@ -151,7 +150,7 @@ static void cgroup__delete(struct cgroup *cgroup) free(cgroup); } -void close_cgroup(struct cgroup *cgrp) +void cgroup__put(struct cgroup *cgrp) { if (cgrp && refcount_dec_and_test(&cgrp->refcnt)) { cgroup__delete(cgrp); diff --git a/tools/perf/util/cgroup.h b/tools/perf/util/cgroup.h index 934daa8e4c197729bcef4ce2e611fa58d8fed4ef..69169fbf8d1388668017caf3c7f635a70cb61789 100644 --- a/tools/perf/util/cgroup.h +++ b/tools/perf/util/cgroup.h @@ -14,7 +14,8 @@ struct cgroup { extern int nr_cgroups; /* number of explicit cgroups defined */ -void close_cgroup(struct cgroup *cgrp); + +void cgroup__put(struct cgroup *cgroup); int parse_cgroups(const struct option *opt, const char *str, int unset); diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index b56e1c2ddaee2e320a7ce437434557f901a8dc47..f1f883bb41a8d1853326058eb94e59237b51e95a 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1233,7 +1233,7 @@ void perf_evsel__exit(struct perf_evsel *evsel) perf_evsel__free_fd(evsel); perf_evsel__free_id(evsel); perf_evsel__free_config_terms(evsel); - close_cgroup(evsel->cgrp); + cgroup__put(evsel->cgrp); cpu_map__put(evsel->cpus); cpu_map__put(evsel->own_cpus); thread_map__put(evsel->threads);