Re: [PATCH 2/4] KVM: VFIO: use mutex guard in kvm_vfio_file_set_spapr_tce()

From: kernel test robot

Date: Mon Apr 06 2026 - 23:49:35 EST


Hi Carlos,

kernel test robot noticed the following build warnings:

[auto build test WARNING on d2ea4ff1ce50787a98a3900b3fb1636f3620b7cf]

url: https://github.com/intel-lab-lkp/linux/commits/Carlos-L-pez/KVM-VFIO-clean-up-control-flow-in-kvm_vfio_file_add/20260314-053050
base: d2ea4ff1ce50787a98a3900b3fb1636f3620b7cf
patch link: https://lore.kernel.org/r/20260313122040.1413091-5-clopez%40suse.de
patch subject: [PATCH 2/4] KVM: VFIO: use mutex guard in kvm_vfio_file_set_spapr_tce()
config: powerpc-allmodconfig (https://download.01.org/0day-ci/archive/20260403/202604031640.vckbuS2S-lkp@xxxxxxxxx/config)
compiler: powerpc64-linux-gcc (GCC) 15.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260403/202604031640.vckbuS2S-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202604031640.vckbuS2S-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

arch/powerpc/kvm/../../../virt/kvm/vfio.c: In function 'kvm_vfio_file_set_spapr_tce':
>> arch/powerpc/kvm/../../../virt/kvm/vfio.c:219:13: warning: unused variable 'ret' [-Wunused-variable]
219 | int ret;
| ^~~


vim +/ret +219 arch/powerpc/kvm/../../../virt/kvm/vfio.c

121f80ba68f1a57 Alexey Kardashevskiy 2017-03-22 211
121f80ba68f1a57 Alexey Kardashevskiy 2017-03-22 212 #ifdef CONFIG_SPAPR_TCE_IOMMU
2f99073a722beef Yi Liu 2023-07-18 213 static int kvm_vfio_file_set_spapr_tce(struct kvm_device *dev,
73b0565f19a8fbc Jason Gunthorpe 2022-05-04 214 void __user *arg)
73b0565f19a8fbc Jason Gunthorpe 2022-05-04 215 {
121f80ba68f1a57 Alexey Kardashevskiy 2017-03-22 216 struct kvm_vfio_spapr_tce param;
121f80ba68f1a57 Alexey Kardashevskiy 2017-03-22 217 struct kvm_vfio *kv = dev->private;
2f99073a722beef Yi Liu 2023-07-18 218 struct kvm_vfio_file *kvf;
73b0565f19a8fbc Jason Gunthorpe 2022-05-04 @219 int ret;
121f80ba68f1a57 Alexey Kardashevskiy 2017-03-22 220
73b0565f19a8fbc Jason Gunthorpe 2022-05-04 221 if (copy_from_user(&param, arg, sizeof(struct kvm_vfio_spapr_tce)))
121f80ba68f1a57 Alexey Kardashevskiy 2017-03-22 222 return -EFAULT;
121f80ba68f1a57 Alexey Kardashevskiy 2017-03-22 223
8152f8201088350 Al Viro 2024-07-19 224 CLASS(fd, f)(param.groupfd);
8152f8201088350 Al Viro 2024-07-19 225 if (fd_empty(f))
121f80ba68f1a57 Alexey Kardashevskiy 2017-03-22 226 return -EBADF;
121f80ba68f1a57 Alexey Kardashevskiy 2017-03-22 227
db3d8c11676213b Carlos López 2026-03-13 228 guard(mutex)(&kv->lock);
121f80ba68f1a57 Alexey Kardashevskiy 2017-03-22 229
2f99073a722beef Yi Liu 2023-07-18 230 list_for_each_entry(kvf, &kv->file_list, node) {
1da91ea87aefe2c Al Viro 2024-05-31 231 if (kvf->file != fd_file(f))
121f80ba68f1a57 Alexey Kardashevskiy 2017-03-22 232 continue;
121f80ba68f1a57 Alexey Kardashevskiy 2017-03-22 233
2f99073a722beef Yi Liu 2023-07-18 234 if (!kvf->iommu_group) {
2f99073a722beef Yi Liu 2023-07-18 235 kvf->iommu_group = kvm_vfio_file_iommu_group(kvf->file);
db3d8c11676213b Carlos López 2026-03-13 236 if (WARN_ON_ONCE(!kvf->iommu_group))
db3d8c11676213b Carlos López 2026-03-13 237 return -EIO;
819da99a7360f7e Jason Gunthorpe 2022-10-07 238 }
d55d9e7a4572182 Jason Gunthorpe 2022-05-04 239
db3d8c11676213b Carlos López 2026-03-13 240 return kvm_spapr_tce_attach_iommu_group(dev->kvm, param.tablefd,
2f99073a722beef Yi Liu 2023-07-18 241 kvf->iommu_group);
121f80ba68f1a57 Alexey Kardashevskiy 2017-03-22 242 }
121f80ba68f1a57 Alexey Kardashevskiy 2017-03-22 243
db3d8c11676213b Carlos López 2026-03-13 244 return -ENOENT;
121f80ba68f1a57 Alexey Kardashevskiy 2017-03-22 245 }
73b0565f19a8fbc Jason Gunthorpe 2022-05-04 246 #endif
73b0565f19a8fbc Jason Gunthorpe 2022-05-04 247

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki