In next commit, it will report users the reason of -EINVAL in map_create. However, as for the check of '!ops' and '!ops->map_mem_usage', it shouldn't report the reason as they would be internal bugs. Instead, add WARN_ON_ONCE to them. Then, it is able to check dmesg to get the error details. Signed-off-by: Leon Hwang --- kernel/bpf/syscall.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index fc1b5c8c5e82f..49db250a2f5da 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -1406,7 +1406,7 @@ static int map_create(union bpf_attr *attr, bpfptr_t uattr) return -EINVAL; map_type = array_index_nospec(map_type, ARRAY_SIZE(bpf_map_types)); ops = bpf_map_types[map_type]; - if (!ops) + if (WARN_ON_ONCE(!ops)) return -EINVAL; if (ops->map_alloc_check) { @@ -1416,7 +1416,7 @@ static int map_create(union bpf_attr *attr, bpfptr_t uattr) } if (attr->map_ifindex) ops = &bpf_map_offload_ops; - if (!ops->map_mem_usage) + if (WARN_ON_ONCE(!ops->map_mem_usage)) return -EINVAL; if (token_flag) { -- 2.51.0