On Tue, Nov 15, 2022 at 06:36:25PM IST, Dan Carpenter wrote: > [ Email screwup on my end means I have to resend two weeks of email. > :/ -dan ] > > Hello Kumar Kartikeya Dwivedi, > > The patch db559117828d: "bpf: Consolidate spin_lock, timer management > into btf_record" from Nov 4, 2022, leads to the following Smatch > static checker warning: > > kernel/bpf/syscall.c:1002 map_check_btf() > warn: ignoring unreachable code. > > kernel/bpf/syscall.c > 946 static int map_check_btf(struct bpf_map *map, const struct btf *btf, > 947 u32 btf_key_id, u32 btf_value_id) > 948 { > 949 const struct btf_type *key_type, *value_type; > 950 u32 key_size, value_size; > 951 int ret = 0; > 952 > 953 /* Some maps allow key to be unspecified. */ > 954 if (btf_key_id) { > 955 key_type = btf_type_id_size(btf, &btf_key_id, &key_size); > 956 if (!key_type || key_size != map->key_size) > 957 return -EINVAL; > 958 } else { > 959 key_type = btf_type_by_id(btf, 0); > 960 if (!map->ops->map_check_btf) > 961 return -EINVAL; > 962 } > 963 > 964 value_type = btf_type_id_size(btf, &btf_value_id, &value_size); > 965 if (!value_type || value_size != map->value_size) > 966 return -EINVAL; > 967 > 968 map->record = btf_parse_fields(btf, value_type, BPF_SPIN_LOCK | BPF_TIMER | BPF_KPTR, > 969 map->value_size); > 970 if (!IS_ERR_OR_NULL(map->record)) { > 971 int i; > 972 > 973 if (!bpf_capable()) { > 974 ret = -EPERM; > 975 goto free_map_tab; > 976 } > 977 if (map->map_flags & (BPF_F_RDONLY_PROG | BPF_F_WRONLY_PROG)) { > 978 ret = -EACCES; > 979 goto free_map_tab; > 980 } > 981 for (i = 0; i < sizeof(map->record->field_mask) * 8; i++) { > 982 switch (map->record->field_mask & (1 << i)) { > 983 case 0: > 984 continue; > 985 case BPF_SPIN_LOCK: > 986 if (map->map_type != BPF_MAP_TYPE_HASH && > 987 map->map_type != BPF_MAP_TYPE_ARRAY && > 988 map->map_type != BPF_MAP_TYPE_CGROUP_STORAGE && > 989 map->map_type != BPF_MAP_TYPE_SK_STORAGE && > 990 map->map_type != BPF_MAP_TYPE_INODE_STORAGE && > 991 map->map_type != BPF_MAP_TYPE_TASK_STORAGE && > 992 map->map_type != BPF_MAP_TYPE_CGRP_STORAGE) { > 993 ret = -EOPNOTSUPP; > 994 goto free_map_tab; > 995 } > 996 break; > 997 case BPF_TIMER: > 998 if (map->map_type != BPF_MAP_TYPE_HASH && > 999 map->map_type != BPF_MAP_TYPE_LRU_HASH && > 1000 map->map_type != BPF_MAP_TYPE_ARRAY) { > 1001 return -EOPNOTSUPP; > ^^^^^^^^^^^^^^^^^^^ > --> 1002 goto free_map_tab; > > s/return/ret =/ > > Surprised the coverity-bot hasn't complained about this... > Thanks, another bad gaffe :/. Fixed locally, will push it out with v8.