FAILED: patch "[PATCH] iommu/virtio: Reset device before deleting virtqueues on probe failure" failed to apply to 5.15-stable tree
Subsystems (3)
Sasha Levin
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 1f8efac19a0870cdfdf8477e447e5a07ddce9623
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From 1f8efac19a0870cdfdf8477e447e5a07ddce9623 Mon Sep 17 00:00:00 2001
From: Yuho Choi <[email protected]>
Date: Sun, 4 Oct 2026 14:21:10 -0400
Subject: [PATCH] iommu/virtio: Reset device before deleting virtqueues on
probe failure
viommu_probe() marks the device DRIVER_OK before populating the event virtqueue and registering the IOMMU device in sysfs. viommu_fill_evtq() hands the device a set of device-writable buffers through virtqueue_add_inbuf(), so from that point on the device may write into them and into the rings.
If either step fails, the error path deletes the virtqueues without resetting the device first. The event buffers are allocated with devm_kmalloc_array() and are released as probe unwinds, so the device can go on writing to memory that has been freed.
Reset the device before deleting the virtqueues, the way viommu_remove() already does.
Message-ID: <[email protected]>
--- drivers/iommu/virtio-iommu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/iommu/virtio-iommu.c +4 -2
@@ -1227,12 +1227,12 @@ static int viommu_probe(struct virtio_device *vdev)/* Populate the event queue with buffers */ ret =viommu_fill_evtq (viommu);if (ret) - goto err_free_vqs; + goto err_reset_vdev; ret =iommu_device_sysfs_add (&viommu->iommu, dev,NULL ,"%s" ,virtio_bus_name (vdev));if (ret) - goto err_free_vqs; + goto err_reset_vdev; vdev->priv = viommu;
@@ -1244,6 +1244,8 @@ static int viommu_probe(struct virtio_device *vdev)return 0 ; +err_reset_vdev: +virtio_reset_device (vdev); err_free_vqs: vdev->config->del_vqs (vdev);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 iommu/virtio: Reset device before deleting virtqueues on probe failure
From: Yuho Choi <[email protected]>
[ Upstream commit 1f8efac19a0870cdfdf8477e447e5a07ddce9623 ]
viommu_probe() marks the device DRIVER_OK before populating the event virtqueue and registering the IOMMU device in sysfs. viommu_fill_evtq() hands the device a set of device-writable buffers through virtqueue_add_inbuf(), so from that point on the device may write into them and into the rings.
If either step fails, the error path deletes the virtqueues without resetting the device first. The event buffers are allocated with devm_kmalloc_array() and are released as probe unwinds, so the device can go on writing to memory that has been freed.
Reset the device before deleting the virtqueues, the way viommu_remove() already does.
Message-ID: <[email protected]>
--- drivers/iommu/virtio-iommu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/iommu/virtio-iommu.c +4 -2
@@ -1061,12 +1061,12 @@ static int viommu_probe(struct virtio_device *vdev)/* Populate the event queue with buffers */ ret =viommu_fill_evtq (viommu);if (ret) - goto err_free_vqs; + goto err_reset_vdev; ret =iommu_device_sysfs_add (&viommu->iommu, dev,NULL ,"%s" ,virtio_bus_name (vdev));if (ret) - goto err_free_vqs; + goto err_reset_vdev;iommu_device_register (&viommu->iommu, &viommu_ops, parent_dev);
@@ -1101,6 +1101,8 @@ static int viommu_probe(struct virtio_device *vdev) err_unregister:iommu_device_sysfs_remove (&viommu->iommu);iommu_device_unregister (&viommu->iommu); +err_reset_vdev: + vdev->config->reset (vdev); err_free_vqs: vdev->config->del_vqs (vdev);
Signature · 1 line
2.53.0