mirror of
https://github.com/torvalds/linux.git
synced 2026-05-29 17:43:52 +02:00
perf maps: Make delete static, always use put
Address/leak sanitizer with reference count checking can identify the location of leaks, so use put rather than delete to avoid free-ing memory when the reference count is >1. Add maps__zput to ensure the variable is cleared. Signed-off-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Ali Saidi <alisaidi@amazon.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com> Cc: Brian Robbins <brianrob@linux.microsoft.com> Cc: Changbin Du <changbin.du@huawei.com> Cc: Dmitrii Dolgov <9erthalion6@gmail.com> Cc: Fangrui Song <maskray@google.com> Cc: German Gomez <german.gomez@arm.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Ivan Babrou <ivan@cloudflare.com> Cc: James Clark <james.clark@arm.com> Cc: Jing Zhang <renyu.zj@linux.alibaba.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: John Garry <john.g.garry@oracle.com> Cc: K Prateek Nayak <kprateek.nayak@amd.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Liam Howlett <liam.howlett@oracle.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Miguel Ojeda <ojeda@kernel.org> Cc: Mike Leach <mike.leach@linaro.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Sean Christopherson <seanjc@google.com> Cc: Steinar H. Gunderson <sesse@google.com> Cc: Suzuki Poulouse <suzuki.poulose@arm.com> Cc: Wenyu Liu <liuwenyu7@huawei.com> Cc: Will Deacon <will@kernel.org> Cc: Yang Jihong <yangjihong1@huawei.com> Cc: Ye Xingchen <ye.xingchen@zte.com.cn> Cc: Yuan Can <yuancan@huawei.com> Cc: coresight@lists.linaro.org Cc: linux-arm-kernel@lists.infradead.org Link: https://lore.kernel.org/r/20230608232823.4027869-5-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
ee84a3032b
commit
46125590e0
|
|
@ -140,7 +140,7 @@ static int test__maps__merge_in(struct test_suite *t __maybe_unused, int subtest
|
|||
ret = check_maps(merged3, ARRAY_SIZE(merged3), maps);
|
||||
TEST_ASSERT_VAL("merge check failed", !ret);
|
||||
|
||||
maps__delete(maps);
|
||||
maps__zput(maps);
|
||||
return TEST_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ void machine__exit(struct machine *machine)
|
|||
return;
|
||||
|
||||
machine__destroy_kernel_maps(machine);
|
||||
maps__delete(machine->kmaps);
|
||||
maps__zput(machine->kmaps);
|
||||
dsos__exit(&machine->dsos);
|
||||
machine__exit_vdso(machine);
|
||||
zfree(&machine->root_dir);
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ struct maps *maps__new(struct machine *machine)
|
|||
return result;
|
||||
}
|
||||
|
||||
void maps__delete(struct maps *maps)
|
||||
static void maps__delete(struct maps *maps)
|
||||
{
|
||||
maps__exit(maps);
|
||||
unwind__finish_access(maps);
|
||||
|
|
|
|||
|
|
@ -57,13 +57,20 @@ struct kmap {
|
|||
};
|
||||
|
||||
struct maps *maps__new(struct machine *machine);
|
||||
void maps__delete(struct maps *maps);
|
||||
bool maps__empty(struct maps *maps);
|
||||
int maps__clone(struct thread *thread, struct maps *parent);
|
||||
|
||||
struct maps *maps__get(struct maps *maps);
|
||||
void maps__put(struct maps *maps);
|
||||
|
||||
static inline void __maps__zput(struct maps **map)
|
||||
{
|
||||
maps__put(*map);
|
||||
*map = NULL;
|
||||
}
|
||||
|
||||
#define maps__zput(map) __maps__zput(&map)
|
||||
|
||||
static inline struct rb_root *maps__entries(struct maps *maps)
|
||||
{
|
||||
return &RC_CHK_ACCESS(maps)->entries;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user