Re: [PATCH v2 2/4] perf symbol: Add missing symsrc__destroy() for libbfd

From: Ian Rogers

Date: Mon Oct 12 2026 - 17:57:24 EST


On Sun, Oct 11, 2026 at 10:30 PM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
>
> 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>

Reviewed-by: Ian Rogers <irogers@xxxxxxxxxx>

Thanks!
Ian

> ---
> tools/perf/util/symbol.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
> index a394e742f9b18812..55a4b59195a08be5 100644
> --- a/tools/perf/util/symbol.c
> +++ b/tools/perf/util/symbol.c
> @@ -1932,7 +1932,7 @@ int dso__load(struct dso *dso, struct map *map)
>
> if (bfdrc > 0) {
> ret = 1;
> - break;
> + goto out_destroy;
> }
>
> if (!is_reg || sirc < 0)
> @@ -1997,6 +1997,7 @@ int dso__load(struct dso *dso, struct map *map)
> ret += nr_plt;
> }
>
> +out_destroy:
> for (; ss_pos > 0; ss_pos--)
> symsrc__destroy(&ss_[ss_pos - 1]);
> out_free:
> --
> 2.55.0
>