Hi Lorenzo,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on bpf-next/master]

url:    
https://github.com/0day-ci/linux/commits/Lorenzo-Bianconi/mvneta-introduce-XDP-multi-buffer-support/20210320-055103
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
compiler: nios2-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <l...@intel.com>


cppcheck warnings: (new ones prefixed by >>)
        ^
   net/core/filter.c:10085:6: note: Variable 'ret' is reassigned a value before 
the old one has been used.
    ret = -EACCES;
        ^
   net/core/filter.c:10090:6: note: Variable 'ret' is reassigned a value before 
the old one has been used.
    ret = fprog->len;
        ^
>> net/core/filter.c:4593:30: warning: Uninitialized variable: copy_len 
>> [uninitvar]
     memcpy(dst_buff, src_buff, copy_len);
                                ^

vim +4593 net/core/filter.c

  4551  
  4552  static unsigned long bpf_xdp_copy(void *dst_buff, const void *ctx,
  4553                                    unsigned long off, unsigned long len)
  4554  {
  4555          struct xdp_buff *xdp = (struct xdp_buff *)ctx;
  4556          struct xdp_shared_info *xdp_sinfo;
  4557          unsigned long base_len;
  4558          const void *src_buff;
  4559  
  4560          if (likely(!xdp->mb)) {
  4561                  src_buff = xdp->data;
  4562                  memcpy(dst_buff, src_buff + off, len);
  4563  
  4564                  return 0;
  4565          }
  4566  
  4567          base_len = xdp->data_end - xdp->data;
  4568          xdp_sinfo = xdp_get_shared_info_from_buff(xdp);
  4569          do {
  4570                  unsigned long copy_len;
  4571  
  4572                  if (off < base_len) {
  4573                          src_buff = xdp->data + off;
  4574                          copy_len = min(len, base_len - off);
  4575                  } else {
  4576                          unsigned long frag_off_total = base_len;
  4577                          int i;
  4578  
  4579                          for (i = 0; i < xdp_sinfo->nr_frags; i++) {
  4580                                  skb_frag_t *frag = &xdp_sinfo->frags[i];
  4581                                  unsigned long frag_len = 
xdp_get_frag_size(frag);
  4582                                  unsigned long frag_off = off - 
frag_off_total;
  4583  
  4584                                  if (frag_off < frag_len) {
  4585                                          src_buff = 
xdp_get_frag_address(frag) +
  4586                                                     frag_off;
  4587                                          copy_len = min(len, frag_len - 
frag_off);
  4588                                          break;
  4589                                  }
  4590                                  frag_off_total += frag_len;
  4591                          }
  4592                  }
> 4593                  memcpy(dst_buff, src_buff, copy_len);
  4594                  off += copy_len;
  4595                  len -= copy_len;
  4596                  dst_buff += copy_len;
  4597          } while (len);
  4598  
  4599          return 0;
  4600  }
  4601  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org

Reply via email to