Skip to contentSkip to conversation

misc: nsm: reset device before deleting the virtqueue on removal

PATCH New Yuho Choi 1 participant 1 message Oct 16

Subsystems (3)
lore
Share & tools
lore

Yuho Choi

author
#0 lore raw

PATCH 1/1 misc: nsm: reset device before deleting the virtqueue on removal

nsm_device_remove() deletes the virtqueue without resetting the device first. del_vqs() frees the vring backing, but does not provide a generic device quiesce operation. In particular, modern virtio-pci keeps enabled queues active until the device is reset, so the device can still access the vring memory after it has been released.

It also leaves the device status at DRIVER_OK, so unbinding the driver trips the WARN_ON_ONCE() in virtio_dev_remove() that checks the driver has reset the device.

Reset the device before deleting the virtqueue.

Fixes b9873755a6c8 ("misc: Add Nitro Secure Module driver")
---
 drivers/misc/nsm.c | 1 +
 1 file changed, 1 insertion(+)
drivers/misc/nsm.c +1 -0
index a3a9f9bfc6b7..7193dfc4343b 100644
@@ -483,6 +483,7 @@ static void nsm_device_remove(struct virtio_device *vdev)
 
 	hwrng_unregister(&nsm->hwrng);
 
+	virtio_reset_device(vdev);
 	vdev->config->del_vqs(vdev);
 	misc_deregister(&nsm->misc);
 }

base-commit: 2f2f7eeef8b0a1a9b9ca998231419873ccae8d4e

Signature · 1 line
2.43.0