:::::: 
:::::: Manual check reason: "low confidence static check warning: 
kernel/bpf/bpf_iter.c:343:13: warning: Uninitialized variable: iter->btf_id 
[uninitvar]"
:::::: 

CC: [email protected]
BCC: [email protected]
CC: [email protected]
TO: Jakob Koschel <[email protected]>
CC: Andrii Nakryiko <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   b047602d579b4fb028128a525f056bbdc890e7f0
commit: 185da3da9379948ffbe45051b16d526c428fb06e bpf: Replace usage of 
supported with dedicated list iterator variable
date:   3 months ago
:::::: branch date: 9 hours ago
:::::: commit date: 3 months ago
compiler: powerpc-linux-gcc (GCC) 11.3.0
reproduce (cppcheck warning):
        # apt-get install cppcheck
        git checkout 185da3da9379948ffbe45051b16d526c428fb06e
        cppcheck --quiet --enable=style,performance,portability --template=gcc 
FILE

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>


cppcheck possible warnings: (new ones prefixed by >>, may not real problems)

   kernel/bpf/bpf_iter.c:456:12: warning: Boolean result is used in bitwise 
operation. Clarify expression with parentheses. [clarifyCondition]
    if (!ulen ^ !ubuf)
              ^
   kernel/bpf/bpf_iter.c:516:29: warning: Boolean result is used in bitwise 
operation. Clarify expression with parentheses. [clarifyCondition]
    if (bpfptr_is_null(ulinfo) ^ !linfo_len)
                               ^
   kernel/bpf/bpf_iter.c:312:26: warning: Uninitialized variable: 
tinfo->reg_info [uninitvar]
     if (reg_info == tinfo->reg_info) {
                            ^
>> kernel/bpf/bpf_iter.c:343:13: warning: Uninitialized variable: iter->btf_id 
>> [uninitvar]
     if (iter->btf_id && iter->btf_id == prog_btf_id) {
               ^
   kernel/bpf/bpf_iter.c:338:13: note: Assuming condition is false
    if (strncmp(attach_fname, prefix, prefix_len))
               ^
   kernel/bpf/bpf_iter.c:343:13: note: Uninitialized variable: iter->btf_id
     if (iter->btf_id && iter->btf_id == prog_btf_id) {
               ^
   kernel/bpf/bpf_iter.c:371:14: warning: Uninitialized variable: tinfo->btf_id 
[uninitvar]
     if (tinfo->btf_id == prog->aux->attach_btf_id) {
                ^
   kernel/bpf/bpf_iter.c:375:8: warning: Uninitialized variable: reg_info 
[uninitvar]
      if (reg_info->get_func_proto)
          ^
   kernel/bpf/bpf_iter.c:374:20: note: Assignment 'reg_info=tinfo->reg_info', 
assigned value is <Uninit>
      reg_info = tinfo->reg_info;
                      ^
   kernel/bpf/bpf_iter.c:375:8: note: Uninitialized variable: reg_info
      if (reg_info->get_func_proto)
          ^

vim +343 kernel/bpf/bpf_iter.c

15d83c4d7cef5c Yonghong Song 2020-05-09  329  
15d83c4d7cef5c Yonghong Song 2020-05-09  330  bool 
bpf_iter_prog_supported(struct bpf_prog *prog)
15d83c4d7cef5c Yonghong Song 2020-05-09  331  {
15d83c4d7cef5c Yonghong Song 2020-05-09  332    const char *attach_fname = 
prog->aux->attach_func_name;
185da3da937994 Jakob Koschel 2022-03-31  333    struct bpf_iter_target_info 
*tinfo = NULL, *iter;
15d83c4d7cef5c Yonghong Song 2020-05-09  334    u32 prog_btf_id = 
prog->aux->attach_btf_id;
15d83c4d7cef5c Yonghong Song 2020-05-09  335    const char *prefix = 
BPF_ITER_FUNC_PREFIX;
15d83c4d7cef5c Yonghong Song 2020-05-09  336    int prefix_len = strlen(prefix);
15d83c4d7cef5c Yonghong Song 2020-05-09  337  
15d83c4d7cef5c Yonghong Song 2020-05-09  338    if (strncmp(attach_fname, 
prefix, prefix_len))
15d83c4d7cef5c Yonghong Song 2020-05-09  339            return false;
15d83c4d7cef5c Yonghong Song 2020-05-09  340  
15d83c4d7cef5c Yonghong Song 2020-05-09  341    mutex_lock(&targets_mutex);
185da3da937994 Jakob Koschel 2022-03-31  342    list_for_each_entry(iter, 
&targets, list) {
185da3da937994 Jakob Koschel 2022-03-31 @343            if (iter->btf_id && 
iter->btf_id == prog_btf_id) {
185da3da937994 Jakob Koschel 2022-03-31  344                    tinfo = iter;
15d83c4d7cef5c Yonghong Song 2020-05-09  345                    break;
15d83c4d7cef5c Yonghong Song 2020-05-09  346            }
185da3da937994 Jakob Koschel 2022-03-31  347            if 
(!strcmp(attach_fname + prefix_len, iter->reg_info->target)) {
185da3da937994 Jakob Koschel 2022-03-31  348                    
cache_btf_id(iter, prog);
185da3da937994 Jakob Koschel 2022-03-31  349                    tinfo = iter;
15d83c4d7cef5c Yonghong Song 2020-05-09  350                    break;
15d83c4d7cef5c Yonghong Song 2020-05-09  351            }
15d83c4d7cef5c Yonghong Song 2020-05-09  352    }
15d83c4d7cef5c Yonghong Song 2020-05-09  353    mutex_unlock(&targets_mutex);
15d83c4d7cef5c Yonghong Song 2020-05-09  354  
185da3da937994 Jakob Koschel 2022-03-31  355    if (tinfo) {
3c32cc1bceba8a Yonghong Song 2020-05-13  356            
prog->aux->ctx_arg_info_size = tinfo->reg_info->ctx_arg_info_size;
3c32cc1bceba8a Yonghong Song 2020-05-13  357            prog->aux->ctx_arg_info 
= tinfo->reg_info->ctx_arg_info;
3c32cc1bceba8a Yonghong Song 2020-05-13  358    }
3c32cc1bceba8a Yonghong Song 2020-05-13  359  
185da3da937994 Jakob Koschel 2022-03-31  360    return tinfo != NULL;
15d83c4d7cef5c Yonghong Song 2020-05-09  361  }
de4e05cac46d20 Yonghong Song 2020-05-09  362  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp
_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to