Skip to content

Commit 77fba26

Browse files
AsphalttKernel Patches Daemon
authored andcommitted
bpf: Add warnings for internal bugs in map_create
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 <[email protected]>
1 parent 88b4130 commit 77fba26

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/bpf/syscall.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,7 @@ static int map_create(union bpf_attr *attr, bpfptr_t uattr)
14061406
return -EINVAL;
14071407
map_type = array_index_nospec(map_type, ARRAY_SIZE(bpf_map_types));
14081408
ops = bpf_map_types[map_type];
1409-
if (!ops)
1409+
if (WARN_ON_ONCE(!ops))
14101410
return -EINVAL;
14111411

14121412
if (ops->map_alloc_check) {
@@ -1416,7 +1416,7 @@ static int map_create(union bpf_attr *attr, bpfptr_t uattr)
14161416
}
14171417
if (attr->map_ifindex)
14181418
ops = &bpf_map_offload_ops;
1419-
if (!ops->map_mem_usage)
1419+
if (WARN_ON_ONCE(!ops->map_mem_usage))
14201420
return -EINVAL;
14211421

14221422
if (token_flag) {

0 commit comments

Comments
 (0)