Skip to contentSkip to conversation

perf bpf: Fix lock/unlock imbalance in perf_env__find_btf() info

PATCH In review Gustavo A. R. Silva 2 participants 3 messages Apr 22, 2019 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf bpf: Fix lock/unlock imbalance in perf_env__find_btf() info

Fix lock/unlock imbalance by moving the call to up_read() just after the *out* label.

Addresses-Coverity-ID: 1444762 ("Missing unlock")

Fixes 2db7b1e0bd49 ("perf bpf: Return NULL when RB tree lookup fails in perf_env__find_btf()")
---
 tools/perf/util/env.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/env.c +1 -1
index 9494f9dc61ec..6a3eaf7d9353 100644
@@ -115,8 +115,8 @@ struct btf_node *perf_env__find_btf(struct perf_env *env, __u32 btf_id)
 	}
 	node = NULL;
 
-	up_read(&env->bpf_progs.lock);
 out:
+	up_read(&env->bpf_progs.lock);
 	return node;
 }
 
Signature · 1 line
2.21.0
#1 lore raw

Em Mon, Apr 22, 2019 at 10:10:56AM -0500, Gustavo A. R. Silva escreveu:

Quoted 15 lines

Fix lock/unlock imbalance by moving the call to up_read() just after the *out* label.

Addresses-Coverity-ID: 1444762 ("Missing unlock")

Fixes 2db7b1e0bd49 ("perf bpf: Return NULL when RB tree lookup fails in perf_env__find_btf()")
---
 tools/perf/util/env.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/env.c +0 -0
index 9494f9dc61ec..6a3eaf7d9353 100644

tools/perf/util/env.c struct btf_node *perf_env__find_btf(struct perf_env *env, __u32 btf_id) · line 121

Quoted 8 lines
tools/perf/util/env.c +1 -1
@@ -115,8 +115,8 @@ struct btf_node *perf_env__find_btf(struct perf_env *env, __u32 btf_id)
 	}
 	node = NULL;
 
-	up_read(&env->bpf_progs.lock);
 out:
+	up_read(&env->bpf_progs.lock);
 	return node;
 }

too late, this was fixed already, also detected by coverity :-)

- Arnaldo

#2 lore raw
Quoted 19 lines · Arnaldo Carvalho de Melo

Em Mon, Apr 22, 2019 at 10:10:56AM -0500, Gustavo A. R. Silva escreveu:

Quoted 18 lines

Fix lock/unlock imbalance by moving the call to up_read() just after the *out* label.

Addresses-Coverity-ID: 1444762 ("Missing unlock")

Fixes 2db7b1e0bd49 ("perf bpf: Return NULL when RB tree lookup fails in perf_env__find_btf()")
---
 tools/perf/util/env.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/env.c +0 -0
index 9494f9dc61ec..6a3eaf7d9353 100644
@@ -115,8 +115,8 @@ struct btf_node *perf_env__find_btf(struct perf_env *env, __u32 btf_id)
 	}
 	node = NULL;
 
Quoted 8 lines

tools/perf/util/env.c struct btf_node *perf_env__find_btf(struct perf_env *env, __u32 btf_id) · line 121

Quoted 5 lines
tools/perf/util/env.c +1 -1
-	up_read(&env->bpf_progs.lock);
 out:
+	up_read(&env->bpf_progs.lock);
 	return node;
 }

too late, this was fixed already, also detected by coverity :-)

Good to know it's fixed now. :)

Thanks
--
Gustavo