Skip to content

Commit

Permalink
bpf: fix range_tree_set error handling
Browse files Browse the repository at this point in the history
`range_tree_set` might fail and return -ENOMEM,
causing subsequent `bpf_arena_alloc_pages` to fail.
Added the error handling.

Signed-off-by: Soma Nakata <[email protected]>
Acked-by: Hou Tao <[email protected]>
  • Loading branch information
Soma Nakata authored and Kernel Patches Daemon committed Jan 8, 2025
1 parent 9632415 commit 312e3d4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kernel/bpf/arena.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ static struct bpf_map *arena_map_alloc(union bpf_attr *attr)
INIT_LIST_HEAD(&arena->vma_list);
bpf_map_init_from_attr(&arena->map, attr);
range_tree_init(&arena->rt);
range_tree_set(&arena->rt, 0, attr->max_entries);
err = range_tree_set(&arena->rt, 0, attr->max_entries);
if (err) {
bpf_map_area_free(arena);
goto err;
}
mutex_init(&arena->lock);

return &arena->map;
Expand Down

0 comments on commit 312e3d4

Please sign in to comment.