Re: [PATCH 04/16] vhost: prep vhost_dev_init users to handle failures

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

 



Hi Mike,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on vhost/linux-next]
[also build test WARNING on next-20201007]
[cannot apply to v5.9-rc8]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Mike-Christie/vhost-fix-scsi-cmd-handling-and-IOPs/20201008-045802
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git linux-next
config: x86_64-randconfig-a016-20201008 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 4d1d8ae7100ec3c7e1709addb7b3ec6f9ad0b44f)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # https://github.com/0day-ci/linux/commit/7dc4d1082d406f391238a1897cb030f33c382bc3
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Mike-Christie/vhost-fix-scsi-cmd-handling-and-IOPs/20201008-045802
        git checkout 7dc4d1082d406f391238a1897cb030f33c382bc3
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

>> drivers/vhost/vdpa.c:820:6: warning: variable 'r' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
           if (vhost_dev_init(dev, vqs, nvqs, 0, 0, 0, false,
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/vhost/vdpa.c:844:9: note: uninitialized use occurs here
           return r;
                  ^
   drivers/vhost/vdpa.c:820:2: note: remove the 'if' if its condition is always false
           if (vhost_dev_init(dev, vqs, nvqs, 0, 0, 0, false,
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/vhost/vdpa.c:798:16: note: initialize the variable 'r' to silence this warning
           int nvqs, i, r, opened;
                         ^
                          = 0
   1 warning generated.

vim +820 drivers/vhost/vdpa.c

   792	
   793	static int vhost_vdpa_open(struct inode *inode, struct file *filep)
   794	{
   795		struct vhost_vdpa *v;
   796		struct vhost_dev *dev;
   797		struct vhost_virtqueue **vqs;
   798		int nvqs, i, r, opened;
   799	
   800		v = container_of(inode->i_cdev, struct vhost_vdpa, cdev);
   801	
   802		opened = atomic_cmpxchg(&v->opened, 0, 1);
   803		if (opened)
   804			return -EBUSY;
   805	
   806		nvqs = v->nvqs;
   807		vhost_vdpa_reset(v);
   808	
   809		vqs = kmalloc_array(nvqs, sizeof(*vqs), GFP_KERNEL);
   810		if (!vqs) {
   811			r = -ENOMEM;
   812			goto err;
   813		}
   814	
   815		dev = &v->vdev;
   816		for (i = 0; i < nvqs; i++) {
   817			vqs[i] = &v->vqs[i];
   818			vqs[i]->handle_kick = handle_vq_kick;
   819		}
 > 820		if (vhost_dev_init(dev, vqs, nvqs, 0, 0, 0, false,
   821				   vhost_vdpa_process_iotlb_msg))
   822			goto err_dev_init;
   823	
   824		dev->iotlb = vhost_iotlb_alloc(0, 0);
   825		if (!dev->iotlb) {
   826			r = -ENOMEM;
   827			goto err_init_iotlb;
   828		}
   829	
   830		r = vhost_vdpa_alloc_domain(v);
   831		if (r)
   832			goto err_init_iotlb;
   833	
   834		filep->private_data = v;
   835	
   836		return 0;
   837	
   838	err_init_iotlb:
   839		vhost_dev_cleanup(&v->vdev);
   840	err_dev_init:
   841		kfree(vqs);
   842	err:
   843		atomic_dec(&v->opened);
   844		return r;
   845	}
   846	

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

Attachment: .config.gz
Description: application/gzip

_______________________________________________
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