Skip to contentSkip to conversation

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

PATCH Applied Jiri Olsa 4 participants 4 messages Apr 17, 2019 – Apr 19, 2019 perf events

lore
Share & tools
lore

Jiri Olsa

author reviewer
#0 lore raw

PATCH 1/1 perf bpf: Return NULL when RB tree lookup fails in perf_env__find_btf()

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

Cc Alexander Shishkin <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Song Liu <[email protected]>
Fixes 3792cb2ff43b ("perf bpf: Save BTF in a rbtree in perf_env")
---
 tools/perf/util/env.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/perf/util/env.c +3 -1
index 34a363f2e71b..9494f9dc61ec 100644
@@ -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;
 }
 
Signature · 1 line
2.17.2
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Jiri Olsa

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

Quoted 8 lines
Cc Alexander Shishkin <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Song Liu <[email protected]>
Fixes 3792cb2ff43b ("perf bpf: Save BTF in a rbtree in perf_env")

Thanks again for the fix!

Quoted 25 lines

---
tools/perf/util/env.c | 4 +++-

1 file changed, 3 insertions(+), 1 deletion(-)
tools/perf/util/env.c +3 -1
index 34a363f2e71b..9494f9dc61ec 100644
@@ -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;
 }
 
Signature · 1 line
2.17.2
#2 lore raw

Em Wed, Apr 17, 2019 at 04:49:13PM +0000, Song Liu escreveu:

Quoted 14 lines
Quoted 5 lines · Jiri Olsa

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

Quoted 8 lines
Cc Alexander Shishkin <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Song Liu <[email protected]>
Fixes 3792cb2ff43b ("perf bpf: Save BTF in a rbtree in perf_env")
Quoted 1 line

Thanks, applied.

- Arnaldo

#3 lore raw
In reply to Jiri Olsa
perf bpf: Return NULL when RB tree lookup fails in perf_env__find_btf()
Commit-ID:  2db7b1e0bd49d2b0e7d16949e167b1cfaf5c07cf
Gitweb:     https://git.kernel.org/tip/2db7b1e0bd49d2b0e7d16949e167b1cfaf5c07cf
Author:     Jiri Olsa <[email protected]>
AuthorDate: Wed, 17 Apr 2019 16:55:39 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 17 Apr 2019 14:30:23 -0300

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

We don't return NULL when we don't find the bpf_prog_info_node, fix that.

Cc Alexander Shishkin <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>
Fixes 3792cb2ff43b ("perf bpf: Save BTF in a rbtree in perf_env")
---
 tools/perf/util/env.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/perf/util/env.c +3 -1
index 34a363f2e71b..9494f9dc61ec 100644
@@ -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;
 }