perf bpf: Return NULL when RB tree lookup fails in perf_env__find_btf()
authorJiri Olsa <jolsa@kernel.org>
Wed, 17 Apr 2019 14:55:39 +0000 (16:55 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 17 Apr 2019 17:30:23 +0000 (14:30 -0300)
We don't return NULL when we don't find the bpf_prog_info_node, fix
that.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Reported-by: Song Liu <songliubraving@fb.com>
Acked-by: Song Liu <songliubraving@fb.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Fixes: 3792cb2ff43b ("perf bpf: Save BTF in a rbtree in perf_env")
Link: http://lkml.kernel.org/r/20190417145539.11669-1-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/env.c

index 34a363f2e71bc0a79838686dd893bbca0ec4142a..9494f9dc61ecac041e114ffa2553e287f416e30d 100644 (file)
@@ -111,10 +111,12 @@ struct btf_node *perf_env__find_btf(struct perf_env *env, __u32 btf_id)
                else if (btf_id > node->id)
                        n = n->rb_right;
                else
-                       break;
+                       goto out;
        }
+       node = NULL;
 
        up_read(&env->bpf_progs.lock);
+out:
        return node;
 }