[jgunthorpe:vfio_group_locking 24/28] drivers/vfio/vfio.c:1152:16: sparse: sparse: Using plain integer as NULL pointer

From: kernel test robot
Date: Thu May 05 2022 - 07:39:32 EST


tree: https://github.com/jgunthorpe/linux vfio_group_locking
head: 0459b33a59543ac21e35b3c9c1ce106968109e6c
commit: bc90cf758ddd2ba50b99a407ec35b5f3c8218662 [24/28] vfio: Split up vfio_group_get_device_fd()
config: h8300-randconfig-s032-20220505 (https://download.01.org/0day-ci/archive/20220505/202205051928.3PBzM39q-lkp@xxxxxxxxx/config)
compiler: h8300-linux-gcc (GCC) 11.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-dirty
# https://github.com/jgunthorpe/linux/commit/bc90cf758ddd2ba50b99a407ec35b5f3c8218662
git remote add jgunthorpe https://github.com/jgunthorpe/linux
git fetch --no-tags jgunthorpe vfio_group_locking
git checkout bc90cf758ddd2ba50b99a407ec35b5f3c8218662
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=h8300 SHELL=/bin/bash drivers/vfio/

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


sparse warnings: (new ones prefixed by >>)
>> drivers/vfio/vfio.c:1152:16: sparse: sparse: Using plain integer as NULL pointer

vim +1152 drivers/vfio/vfio.c

1106
1107 static struct file *vfio_device_open(struct vfio_device *device)
1108 {
1109 struct file *filep;
1110 int ret;
1111
1112 ret = vfio_device_assign_container(device);
1113 if (ret)
1114 return ERR_PTR(ret);
1115
1116 if (!try_module_get(device->dev->driver->owner)) {
1117 ret = -ENODEV;
1118 goto err_unassign_container;
1119 }
1120
1121 mutex_lock(&device->dev_set->lock);
1122 device->open_count++;
1123 if (device->open_count == 1 && device->ops->open_device) {
1124 ret = device->ops->open_device(device);
1125 if (ret)
1126 goto err_undo_count;
1127 }
1128 mutex_unlock(&device->dev_set->lock);
1129
1130 /*
1131 * We can't use anon_inode_getfd() because we need to modify
1132 * the f_mode flags directly to allow more than just ioctls
1133 */
1134 filep = anon_inode_getfile("[vfio-device]", &vfio_device_fops,
1135 device, O_RDWR);
1136 if (IS_ERR(filep)) {
1137 ret = PTR_ERR(filep);
1138 goto err_close_device;
1139 }
1140
1141 /*
1142 * TODO: add an anon_inode interface to do this.
1143 * Appears to be missing by lack of need rather than
1144 * explicitly prevented. Now there's need.
1145 */
1146 filep->f_mode |= (FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE);
1147
1148 /*
1149 * On success the ref of device is moved to the file and
1150 * put in vfio_device_fops_release()
1151 */
> 1152 return 0;
1153
1154 err_close_device:
1155 mutex_lock(&device->dev_set->lock);
1156 if (device->open_count == 1 && device->ops->close_device)
1157 device->ops->close_device(device);
1158 err_undo_count:
1159 device->open_count--;
1160 mutex_unlock(&device->dev_set->lock);
1161 module_put(device->dev->driver->owner);
1162 err_unassign_container:
1163 vfio_group_try_dissolve_container(device->group);
1164 return ERR_PTR(ret);
1165 }
1166

--
0-DAY CI Kernel Test Service
https://01.org/lkp