Re: [PATCH v2 bpf-next 02/13] bpf: Migrate release_on_unlock logic to non-owning ref semantics

Dan Carpenter
2022-12-23T10:51:36Z

Hi Dave,

url: https://github.com/intel-lab-lkp/linux/commits/Dave-Marchevsky/BPF-rbtree-next-gen-datastructure/20221217-162646
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
patch link: https://lore.kernel.org/r/20221217082506.1570898-3-davemarchevsky%40fb.com
patch subject: [PATCH v2 bpf-next 02/13] bpf: Migrate release_on_unlock logic to non-owning ref semantics
config: x86_64-randconfig-m001
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>

smatch warnings:
kernel/bpf/verifier.c:6275 reg_find_field_offset() warn: variable dereferenced before check 'reg' (see line 6274)

vim +/reg +6275 kernel/bpf/verifier.c

4ed17b8d6842ba Dave Marchevsky 2022-12-17 6268 static struct btf_field *
4ed17b8d6842ba Dave Marchevsky 2022-12-17 6269 reg_find_field_offset(const struct bpf_reg_state *reg, s32 off, u32 fields)
4ed17b8d6842ba Dave Marchevsky 2022-12-17 6270 {
4ed17b8d6842ba Dave Marchevsky 2022-12-17 6271 struct btf_field *field;
4ed17b8d6842ba Dave Marchevsky 2022-12-17 6272 struct btf_record *rec;
4ed17b8d6842ba Dave Marchevsky 2022-12-17 6273
4ed17b8d6842ba Dave Marchevsky 2022-12-17 @6274 rec = reg_btf_record(reg);
4ed17b8d6842ba Dave Marchevsky 2022-12-17 @6275 if (!reg)

Is this supposed to test rec instead of reg?

4ed17b8d6842ba Dave Marchevsky 2022-12-17 6276 return NULL;
4ed17b8d6842ba Dave Marchevsky 2022-12-17 6277
4ed17b8d6842ba Dave Marchevsky 2022-12-17 6278 field = btf_record_find(rec, off, fields);
4ed17b8d6842ba Dave Marchevsky 2022-12-17 6279 if (!field)
4ed17b8d6842ba Dave Marchevsky 2022-12-17 6280 return NULL;
4ed17b8d6842ba Dave Marchevsky 2022-12-17 6281
4ed17b8d6842ba Dave Marchevsky 2022-12-17 6282 return field;
4ed17b8d6842ba Dave Marchevsky 2022-12-17 6283 }

--
0-DAY CI Kernel Test Service