Commit ec42d3d5 authored by Ian Rogers's avatar Ian Rogers Committed by Namhyung Kim
Browse files

perf map: Fix map reference count issues



The find will get the map, ensure puts are done on all paths.

Signed-off-by: default avatarIan Rogers <irogers@google.com>
Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240229062048.558799-1-irogers@google.com
parent 1947b924
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -611,14 +611,14 @@ struct symbol *maps__find_symbol(struct maps *maps, u64 addr, struct map **mapp)
	struct symbol *result = NULL;

	/* Ensure map is loaded before using map->map_ip */
	if (map != NULL && map__load(map) >= 0) {
	if (map != NULL && map__load(map) >= 0)
		result = map__find_symbol(map, map__map_ip(map, addr));

	if (mapp)
		*mapp = map;

		result = map__find_symbol(map, map__map_ip(map, addr));
		if (!mapp)
	else
		map__put(map);
	}

	return result;
}

+1 −3
Original line number Diff line number Diff line
@@ -2274,9 +2274,7 @@ static int find_perf_probe_point_from_map(struct probe_trace_point *tp,
	ret = pp->function ? 0 : -ENOMEM;

out:
	if (map && !is_kprobe) {
	map__put(map);
	}

	return ret;
}