perf symbol-elf: Ensure dso__put() in machine__process_ksymbol_register()
authorIan Rogers <irogers@google.com>
Mon, 6 May 2024 18:01:02 +0000 (11:01 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 6 May 2024 19:06:29 +0000 (16:06 -0300)
commitee5061f82449f7ac867a39daae64c9f9681156e8
treee5c1274235a390a032f97c4da1e57bb9872e98e6
parent7fdc33f84261466591fc00e66168d9c809e7e4c0
perf symbol-elf: Ensure dso__put() in machine__process_ksymbol_register()

The dso__put() after the map creation causes a use after put in
dso__set_loaded().

To ensure there is a +1 reference count on both sides of the if-else, do
a dso__get() on the found map's dso.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Changbin Du <changbin.du@huawei.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
Link: https://lore.kernel.org/r/20240506180104.485674-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/machine.c