[bug report] vdpa: set the virtqueue num during register

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Jason Wang,

The patch ddd50f4495d3: "vdpa: set the virtqueue num during register"
from Feb 23, 2021, leads to the following static checker warning:

	drivers/vdpa/ifcvf/ifcvf_main.c:433 ifcvf_probe()
	warn: risky error pointer math: '__vdpa_alloc_device(dev, &ifc_vdpa_ops, 2592 + (0), (0)))'

include/linux/vdpa.h
   255  #define vdpa_alloc_device(dev_struct, member, parent, config, name)   \
   256                            container_of(__vdpa_alloc_device( \
   257                                         parent, config, \
   258                                         sizeof(dev_struct) + \
   259                                         BUILD_BUG_ON_ZERO(offsetof( \
   260                                         dev_struct, member)), name), \
   261                                         dev_struct, member)
   262  

The __vdpa_alloc_device() returns an error pointer and if we call
container_of() on then that's a bug...  (Unless the container_of() is
known to be a no-op, in which case it's sort of ugly but fine, I guess.
There is one caller where this is the case.).

drivers/vdpa/ifcvf/ifcvf_main.c
   432  
   433          adapter = vdpa_alloc_device(struct ifcvf_adapter, vdpa,
   434                                      dev, &ifc_vdpa_ops, NULL);
   435          if (adapter == NULL) {

All the other caller check for NULL.  :P

   436                  IFCVF_ERR(pdev, "Failed to allocate vDPA structure");
   437                  return -ENOMEM;
   438          }
   439  
   440          pci_set_master(pdev);
   441          pci_set_drvdata(pdev, adapter);
   442  

regards,
dan carpenter
_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization



[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux