Skip to content

Commit ec42d3d

Browse files
captain5050namhyung
authored andcommitted
perf map: Fix map reference count issues
The find will get the map, ensure puts are done on all paths. Signed-off-by: Ian Rogers <[email protected]> Acked-by: Namhyung Kim <[email protected]> Cc: Masami Hiramatsu <[email protected]> Signed-off-by: Namhyung Kim <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 1947b92 commit ec42d3d

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

tools/perf/util/maps.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -611,14 +611,14 @@ struct symbol *maps__find_symbol(struct maps *maps, u64 addr, struct map **mapp)
611611
struct symbol *result = NULL;
612612

613613
/* Ensure map is loaded before using map->map_ip */
614-
if (map != NULL && map__load(map) >= 0) {
615-
if (mapp)
616-
*mapp = map;
617-
614+
if (map != NULL && map__load(map) >= 0)
618615
result = map__find_symbol(map, map__map_ip(map, addr));
619-
if (!mapp)
620-
map__put(map);
621-
}
616+
617+
if (mapp)
618+
*mapp = map;
619+
else
620+
map__put(map);
621+
622622
return result;
623623
}
624624

tools/perf/util/probe-event.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,9 +2274,7 @@ static int find_perf_probe_point_from_map(struct probe_trace_point *tp,
22742274
ret = pp->function ? 0 : -ENOMEM;
22752275

22762276
out:
2277-
if (map && !is_kprobe) {
2278-
map__put(map);
2279-
}
2277+
map__put(map);
22802278

22812279
return ret;
22822280
}

0 commit comments

Comments
 (0)