Skip to content

Commit 64a064c

Browse files
RtoaxAlexei Starovoitov
authored andcommitted
selftests/bpf: rbtree: Fix incorrect global variable usage
Within __add_three() function, should use function parameters instead of global variables. So that the variables groot_nested.inner.root and groot_nested.inner.glock in rbtree_add_nodes_nested() are tested correctly. Signed-off-by: Rong Tao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent a570f38 commit 64a064c

File tree

1 file changed

+7
-7
lines changed
  • tools/testing/selftests/bpf/progs

1 file changed

+7
-7
lines changed

tools/testing/selftests/bpf/progs/rbtree.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,19 @@ static long __add_three(struct bpf_rb_root *root, struct bpf_spin_lock *lock)
6161
}
6262
m->key = 1;
6363

64-
bpf_spin_lock(&glock);
65-
bpf_rbtree_add(&groot, &n->node, less);
66-
bpf_rbtree_add(&groot, &m->node, less);
67-
bpf_spin_unlock(&glock);
64+
bpf_spin_lock(lock);
65+
bpf_rbtree_add(root, &n->node, less);
66+
bpf_rbtree_add(root, &m->node, less);
67+
bpf_spin_unlock(lock);
6868

6969
n = bpf_obj_new(typeof(*n));
7070
if (!n)
7171
return 3;
7272
n->key = 3;
7373

74-
bpf_spin_lock(&glock);
75-
bpf_rbtree_add(&groot, &n->node, less);
76-
bpf_spin_unlock(&glock);
74+
bpf_spin_lock(lock);
75+
bpf_rbtree_add(root, &n->node, less);
76+
bpf_spin_unlock(lock);
7777
return 0;
7878
}
7979

0 commit comments

Comments
 (0)