Skip to contentSkip to conversation

perf annotate: Fix multiple memory and file descriptor leaks

PATCH Applied Gustavo A. R. Silva 4 participants 4 messages Oct 14, 2019 – Oct 21, 2019 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf annotate: Fix multiple memory and file descriptor leaks

Store SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF in variable *ret*, instead of returning in the middle of the function and leaking multiple
resources: prog_linfo, btf, s and bfdf.

Addresses-Coverity-ID: 1454832 ("Structurally dead code")

Fixes 11aad897f6d1 ("perf annotate: Don't return -1 for error when doing BPF disassembly")
---
 tools/perf/util/annotate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/annotate.c +1 -1
index 4036c7f7b0fb..e42bf572358c 100644
@@ -1758,7 +1758,7 @@ static int symbol__disassemble_bpf(struct symbol *sym,
 	info_node = perf_env__find_bpf_prog_info(dso->bpf_prog.env,
 						 dso->bpf_prog.id);
 	if (!info_node) {
-		return SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF;
+		ret = SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF;
 		goto out;
 	}
 	info_linear = info_node->info_linear;
Signature · 1 line
2.23.0
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Gustavo A. R. Silva

Store SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF in variable *ret*, instead of returning in the middle of the function and leaking multiple
resources: prog_linfo, btf, s and bfdf.

Addresses-Coverity-ID: 1454832 ("Structurally dead code")

Fixes 11aad897f6d1 ("perf annotate: Don't return -1 for error when doing BPF disassembly")

thanks,
jirka

Quoted 20 lines
---
 tools/perf/util/annotate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/annotate.c +1 -1
index 4036c7f7b0fb..e42bf572358c 100644
@@ -1758,7 +1758,7 @@ static int symbol__disassemble_bpf(struct symbol *sym,
 	info_node = perf_env__find_bpf_prog_info(dso->bpf_prog.env,
 						 dso->bpf_prog.id);
 	if (!info_node) {
-		return SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF;
+		ret = SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF;
 		goto out;
 	}
 	info_linear = info_node->info_linear;
Signature · 1 line
2.23.0
#2 lore raw

Em Tue, Oct 15, 2019 at 10:46:32AM +0200, Jiri Olsa escreveu:

Quoted 18 lines · Gustavo A. R. Silva
Quoted 7 lines

Store SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF in variable *ret*, instead of returning in the middle of the function and leaking multiple
resources: prog_linfo, btf, s and bfdf.

Addresses-Coverity-ID: 1454832 ("Structurally dead code")

Fixes 11aad897f6d1 ("perf annotate: Don't return -1 for error when doing BPF disassembly")

thanks,
jirka

Quoted 4 lines
---
 tools/perf/util/annotate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 11 lines

tools/perf/util/annotate.c static int symbol__disassemble_bpf(struct symbol *sym, · line 1762

Quoted 11 lines
tools/perf/util/annotate.c +1 -1
index 4036c7f7b0fb..e42bf572358c 100644
@@ -1758,7 +1758,7 @@ static int symbol__disassemble_bpf(struct symbol *sym,
 	info_node = perf_env__find_bpf_prog_info(dso->bpf_prog.env,
 						 dso->bpf_prog.id);
 	if (!info_node) {
-		return SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF;
+		ret = SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF;
 		goto out;

Ouch, unreachable goto, /me ducks

- Arnaldo

Quoted 5 lines
Quoted 5 lines
tools/perf/util/annotate.c +0 -0
 	}
 	info_linear = info_node->info_linear;
Signature · 1 line
2.23.0
Signature · 1 line
- Arnaldo
#3 lore raw
In reply to Gustavo A. R. Silva
The following commit has been merged into the perf/urgent branch of tip:

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     f948eb45e3af9fb18a0487d0797a773897ef6929
Gitweb:        https://git.kernel.org/tip/f948eb45e3af9fb18a0487d0797a773897ef6929
Author:        Gustavo A. R. Silva <[email protected]>
AuthorDate:    Mon, 14 Oct 2019 12:10:47 -05:00
Committer:     Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Tue, 15 Oct 2019 12:00:01 -03:00

perf annotate: Fix multiple memory and file descriptor leaks

Store SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF in variable *ret*, instead of returning in the middle of the function and leaking multiple
resources: prog_linfo, btf, s and bfdf.

Addresses-Coverity-ID: 1454832 ("Structurally dead code")

Fixes 11aad897f6d1 ("perf annotate: Don't return -1 for error when doing BPF disassembly")
Cc Alexander Shishkin <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 tools/perf/util/annotate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/annotate.c +1 -1
index 4036c7f..e42bf57 100644
@@ -1758,7 +1758,7 @@ static int symbol__disassemble_bpf(struct symbol *sym,
 	info_node = perf_env__find_bpf_prog_info(dso->bpf_prog.env,
 						 dso->bpf_prog.id);
 	if (!info_node) {
-		return SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF;
+		ret = SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF;
 		goto out;
 	}
 	info_linear = info_node->info_linear;