perf bpf: Return value with unlocking in perf_env__find_btf() [Linux 5.1]

perf bpf: Return value with unlocking in perf_env__find_btf() [Linux 5.1]

This Linux kernel change "perf bpf: Return value with unlocking in perf_env__find_btf()" is included in the Linux 5.1 release. This change is authored by Bo YU <tsu.yubo [at] gmail.com> on Mon Apr 22 04:01:38 2019 -0400. The commit for this change in Linux stable tree is 2e71267 (patch).

perf bpf: Return value with unlocking in perf_env__find_btf()

In perf_env__find_btf(), we're returning without unlocking
"env->bpf_progs.lock". There may be cause lockdep issue.

Detected by CoversityScan, CID# 1444762:(program hangs(LOCK))

Signed-off-by: Bo YU <[email protected]>
Acked-by: Jiri Olsa <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Alexei Starovoitov <[email protected]>
Cc: Daniel Borkmann <[email protected]>
Cc: Martin KaFai Lau <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Song Liu <[email protected]>
Cc: Yonghong Song <[email protected]>
Cc: [email protected]
Cc: [email protected]
Fixes: 2db7b1e0bd49d: (perf bpf: Return NULL when RB tree lookup fails in perf_env__find_btf())
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>

There are 2 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 tools/perf/util/env.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c
index 9494f9d..6a3eaf7 100644
--- a/tools/perf/util/env.c
+++ b/tools/perf/util/env.c
@@ -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;
 }

Leave a Reply

Your email address will not be published. Required fields are marked *