Messages in this thread Patch in this message | | | From | Yafang Shao <> | Subject | [RFC PATCH bpf-next 04/13] bpf: No need to check if id is 0 | Date | Sun, 26 Mar 2023 09:21:59 +0000 |
| |
idr_alloc_cyclic() will return -ENOSPC if there's no available IDs, so don't need to check if the id is less than the start number.
Signed-off-by: Yafang Shao <laoar.shao@gmail.com> --- kernel/bpf/syscall.c | 7 ------- 1 file changed, 7 deletions(-)
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index e18ac7f..f3664f2 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -387,9 +387,6 @@ static int bpf_map_alloc_id(struct bpf_map *map) spin_unlock_bh(&map_idr_lock); idr_preload_end(); - if (WARN_ON_ONCE(!id)) - return -ENOSPC; - return id > 0 ? 0 : id; } @@ -2032,10 +2029,6 @@ static int bpf_prog_alloc_id(struct bpf_prog *prog) spin_unlock_bh(&prog_idr_lock); idr_preload_end(); - /* id is in [1, INT_MAX) */ - if (WARN_ON_ONCE(!id)) - return -ENOSPC; - return id > 0 ? 0 : id; } -- 1.8.3.1
| |