[PATCH v1 2/2] perf symbol: Add missing symsrc__destroy() for libbfd

From: Namhyung Kim

Date: Sat Oct 10 2026 - 03:58:26 EST


When libbfd loaded symbols and there's a pending syms_ss, it'd be lost
or overwrite existing symbols. Let's destroy it before breaking the
loop so that it can safely return from the function.

Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
Closes: https://lore.kernel.org/r/sashiko-outbox-162540@xxxxxxxxxx
Fixes: eac9a4342e5447cad ("perf symbols: Try reading the symbol table with libbfd")
Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
tools/perf/util/symbol.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 4d6c5d60cbaa693f..4335e6549d0aecf0 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1935,6 +1935,10 @@ int dso__load(struct dso *dso, struct map *map)

if (bfdrc > 0) {
dso__set_symtab_type(dso, symtab_type);
+ if (syms_ss) {
+ symsrc__destroy(syms_ss);
+ syms_ss = NULL;
+ }
ret = 1;
break;
}
--
2.55.0