diff options
| author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2023-04-18 17:33:48 -0300 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2023-04-19 10:52:54 -0300 |
| commit | fe693d951e3c303b4fb6c712f8affecbe9e8b001 (patch) | |
| tree | 8e38165abc611742b25d7a1f2bfed3406c361193 /tools/perf/util/maps.c | |
| parent | 3ad1be6faef9a482c3098928220fcafaa51a1283 (diff) | |
| download | linux-fe693d951e3c303b4fb6c712f8affecbe9e8b001.tar.gz linux-fe693d951e3c303b4fb6c712f8affecbe9e8b001.tar.bz2 linux-fe693d951e3c303b4fb6c712f8affecbe9e8b001.zip | |
perf maps: Add maps__refcnt() accessor to allow checking maps pointer
To remove one more direct access to 'struct maps' so that we can
intercept accesses to its instantiations and refcount check it to catch
use after free, etc.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/maps.c')
| -rw-r--r-- | tools/perf/util/maps.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/perf/util/maps.c b/tools/perf/util/maps.c index 5afed53ea0b4..953dc20d55d7 100644 --- a/tools/perf/util/maps.c +++ b/tools/perf/util/maps.c @@ -12,13 +12,13 @@ static void maps__init(struct maps *maps, struct machine *machine) { + refcount_set(maps__refcnt(maps), 1); maps->entries = RB_ROOT; init_rwsem(maps__lock(maps)); maps->machine = machine; maps->last_search_by_name = NULL; maps->nr_maps = 0; maps->maps_by_name = NULL; - refcount_set(&maps->refcnt, 1); } static void __maps__free_maps_by_name(struct maps *maps) @@ -180,14 +180,14 @@ void maps__delete(struct maps *maps) struct maps *maps__get(struct maps *maps) { if (maps) - refcount_inc(&maps->refcnt); + refcount_inc(maps__refcnt(maps)); return maps; } void maps__put(struct maps *maps) { - if (maps && refcount_dec_and_test(&maps->refcnt)) + if (maps && refcount_dec_and_test(maps__refcnt(maps))) maps__delete(maps); } |
