]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iommufd/viommu: Release the igroup lock on the vdevice_size error path
authorNicolin Chen <nicolinc@nvidia.com>
Mon, 6 Jul 2026 05:36:09 +0000 (22:36 -0700)
committerJason Gunthorpe <jgg@nvidia.com>
Tue, 14 Jul 2026 13:51:56 +0000 (10:51 -0300)
iommufd_vdevice_alloc_ioctl() takes idev->igroup->lock, then validates the
driver's vdevice_size against the core structure size with a WARN_ON_ONCE.
On failure that guard jumps to out_put_idev, below out_unlock_igroup, so it
skips the mutex_unlock(), leaving the igroup lock held and deadlocking the
next vDEVICE operation on that group.

Jump to out_unlock_igroup instead.

Fixes: ed42eee797ff3 ("iommufd/viommu: Add driver-defined vDEVICE support")
Link: https://patch.msgid.link/r/e903f775d491296a525097e2a90b3eb6a47cf2ef.1783311134.git.nicolinc@nvidia.com
Cc: stable@vger.kernel.org
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Assisted-by: Claude:claude-opus-4-8
Reviewed-by: Pranjal Shrivastava <praan@google.com>
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/iommu/iommufd/viommu.c

index 4081deda9b33d0b19c645f63605f2408b9c0e2fb..0c12c7e352a14565df62cee038516c12c2d70999 100644 (file)
@@ -189,7 +189,7 @@ int iommufd_vdevice_alloc_ioctl(struct iommufd_ucmd *ucmd)
                if (WARN_ON_ONCE(viommu->ops->vdevice_size < vdev_size ||
                                 !viommu->ops->vdevice_init)) {
                        rc = -EOPNOTSUPP;
-                       goto out_put_idev;
+                       goto out_unlock_igroup;
                }
                vdev_size = viommu->ops->vdevice_size;
        }