[PATCH v1 03/17] perf symbol-elf: Add missing puts on error path

Ian Rogers posted 17 patches 1 week, 2 days ago
[PATCH v1 03/17] perf symbol-elf: Add missing puts on error path
Posted by Ian Rogers 1 week, 2 days ago
In dso__process_kernel_symbol if inserting a map fails, probably
ENOMEM, then the reference count puts were missing on the dso and map.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/util/symbol-elf.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 9e820599bab3..4c76e680b13d 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -1446,8 +1446,11 @@ static int dso__process_kernel_symbol(struct dso *dso, struct map *map,
 			map__set_mapping_type(curr_map, MAPPING_TYPE__IDENTITY);
 		}
 		dso__set_symtab_type(curr_dso, dso__symtab_type(dso));
-		if (maps__insert(kmaps, curr_map))
+		if (maps__insert(kmaps, curr_map)) {
+			dso__put(curr_dso);
+			map__put(curr_map);
 			return -1;
+		}
 		dsos__add(&maps__machine(kmaps)->dsos, curr_dso);
 		dso__set_loaded(curr_dso);
 		dso__put(*curr_dsop);
-- 
2.52.0.rc2.455.g230fcf2819-goog
Re: [PATCH v1 03/17] perf symbol-elf: Add missing puts on error path
Posted by Arnaldo Carvalho de Melo 7 hours ago
On Sat, Nov 22, 2025 at 12:19:15AM -0800, Ian Rogers wrote:
> In dso__process_kernel_symbol if inserting a map fails, probably
> ENOMEM, then the reference count puts were missing on the dso and map.

Reviewed-by: Arnaldo Carvalho de Melo <acme@redhat.com>

- Arnaldo
 
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
>  tools/perf/util/symbol-elf.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
> index 9e820599bab3..4c76e680b13d 100644
> --- a/tools/perf/util/symbol-elf.c
> +++ b/tools/perf/util/symbol-elf.c
> @@ -1446,8 +1446,11 @@ static int dso__process_kernel_symbol(struct dso *dso, struct map *map,
>  			map__set_mapping_type(curr_map, MAPPING_TYPE__IDENTITY);
>  		}
>  		dso__set_symtab_type(curr_dso, dso__symtab_type(dso));
> -		if (maps__insert(kmaps, curr_map))
> +		if (maps__insert(kmaps, curr_map)) {
> +			dso__put(curr_dso);
> +			map__put(curr_map);
>  			return -1;
> +		}
>  		dsos__add(&maps__machine(kmaps)->dsos, curr_dso);
>  		dso__set_loaded(curr_dso);
>  		dso__put(*curr_dsop);
> -- 
> 2.52.0.rc2.455.g230fcf2819-goog