Re: [PATCH v1 2/2] iommu/virtio: Handle iommu_device_register() failures
From: Will Deacon
Date: Wed Jul 15 2026 - 07:54:34 EST
On Tue, Jul 14, 2026 at 10:49:49AM +0800, weimin xiong wrote:
> From: Xiong Weimin <xiongweimin@xxxxxxxxxx>
>
> iommu_device_register() returns an error when the IOMMU core fails to
> register the hardware instance or probe the buses. viommu_probe()
> currently ignores that error and continues as if the device was
> registered successfully.
>
> Propagate the failure and unwind the sysfs entry and virtqueues that
> were set up earlier. Clear the driver data on the error path as well,
> since it is set before registration so bus probing can find the
> virtio-IOMMU instance.
>
> Signed-off-by: Xiong Weimin <xiongweimin@xxxxxxxxxx>
> ---
> drivers/iommu/virtio-iommu.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c
> index 342785c76..9118377d7 100644
> --- a/drivers/iommu/virtio-iommu.c
> +++ b/drivers/iommu/virtio-iommu.c
> @@ -1240,7 +1240,9 @@ static int viommu_probe(struct virtio_device *vdev)
>
> vdev->priv = viommu;
>
> - iommu_device_register(&viommu->iommu, &viommu_ops, parent_dev);
> + ret = iommu_device_register(&viommu->iommu, &viommu_ops, parent_dev);
> + if (ret)
> + goto err_remove_sysfs;
Given that the first patch shouldn't be needed (per Robin's comments at
[1]) and this is augmented an error path that we shouldn't be hitting in
practice, I don't think we need to treat this as a fix. You can probably
just lump it in with your virtio-iommu hardening series.
Will