lkml.org 
[lkml]   [2023]   [Mar]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH bpf-next 04/13] bpf: No need to check if id is 0
Date
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
\
 
 \ /
  Last update: 2023-03-27 01:17    [W:0.199 / U:0.744 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site