[tip:perf/urgent] perf bpf: Return NULL when RB tree lookup fails in perf_env__find_bpf_prog_info()

From: tip-bot for Jiri Olsa
Date: Fri Apr 19 2019 - 15:06:23 EST


Commit-ID: aa52660231410b13d237299e691c43e346e3a73f
Gitweb: https://git.kernel.org/tip/aa52660231410b13d237299e691c43e346e3a73f
Author: Jiri Olsa <jolsa@xxxxxxxxxx>
AuthorDate: Tue, 16 Apr 2019 15:41:51 +0200
Committer: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
CommitDate: Wed, 17 Apr 2019 14:30:06 -0300

perf bpf: Return NULL when RB tree lookup fails in perf_env__find_bpf_prog_info()

We currently don't return NULL in case we don't find the
bpf_prog_info_node, fixing that.

Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
Acked-by: Song Liu <songliubraving@xxxxxx>
Cc: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Fixes: e4378f0cb90b ("perf bpf: Save bpf_prog_info in a rbtree in perf_env")
Link: http://lkml.kernel.org/r/20190416134151.15282-1-jolsa@xxxxxxxxxx
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
tools/perf/util/env.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c
index c6351b557bb0..34a363f2e71b 100644
--- a/tools/perf/util/env.c
+++ b/tools/perf/util/env.c
@@ -57,9 +57,11 @@ struct bpf_prog_info_node *perf_env__find_bpf_prog_info(struct perf_env *env,
else if (prog_id > node->info_linear->info.id)
n = n->rb_right;
else
- break;
+ goto out;
}
+ node = NULL;

+out:
up_read(&env->bpf_progs.lock);
return node;
}