Skip to content

Commit b8b1e30

Browse files
Soma NakataAlexei Starovoitov
authored andcommitted
bpf: Fix range_tree_set() error handling
range_tree_set() might fail and return -ENOMEM, causing subsequent `bpf_arena_alloc_pages` to fail. Add the error handling. Signed-off-by: Soma Nakata <[email protected]> Acked-by: Hou Tao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent bab18c7 commit b8b1e30

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

kernel/bpf/arena.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,11 @@ static struct bpf_map *arena_map_alloc(union bpf_attr *attr)
138138
INIT_LIST_HEAD(&arena->vma_list);
139139
bpf_map_init_from_attr(&arena->map, attr);
140140
range_tree_init(&arena->rt);
141-
range_tree_set(&arena->rt, 0, attr->max_entries);
141+
err = range_tree_set(&arena->rt, 0, attr->max_entries);
142+
if (err) {
143+
bpf_map_area_free(arena);
144+
goto err;
145+
}
142146
mutex_init(&arena->lock);
143147

144148
return &arena->map;

0 commit comments

Comments
 (0)