Skip to contentSkip to conversation

virtio_blk: Reset device on probe error paths after DRIVER_OK

PATCH In review Yuho Choi 3 participants 3 messages Sep 22 – Oct 1

Subsystems (4)
lore
Share & tools
lore

Yuho Choi

author
#0 lore raw

PATCH 1/1 virtio_blk: Reset device on probe error paths after DRIVER_OK

virtblk_probe() marks the device ready before revalidating zones and adding the disk, and either of those can fail. The out_cleanup_disk path they take goes on to delete the virtqueues, but nothing tells the device to stop first, so it is still live when the rings are freed.

Reset the device at out_cleanup_disk, which is only reachable after virtio_device_ready(). virtblk_remove() and virtblk_freeze_priv() both reset before deleting the virtqueues for the same reason.

Fixes dbb301f91fc8 ("virtio_blk: add error handling support for add_disk()")
---
 drivers/block/virtio_blk.c | 1 +
 1 file changed, 1 insertion(+)
drivers/block/virtio_blk.c +1 -0
index 32bf3ba07a9dc..ed97dafebe164 100644
@@ -1547,6 +1547,7 @@ static int virtblk_probe(struct virtio_device *vdev)
 	return 0;
 
 out_cleanup_disk:
+	virtio_reset_device(vdev);
 	put_disk(vblk->disk);
 out_free_tags:
 	blk_mq_free_tag_set(&vblk->tag_set);
Signature · 1 line
2.43.0
#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 11 lines

virtblk_probe() marks the device ready before revalidating zones and adding the disk, and either of those can fail. The out_cleanup_disk path they take goes on to delete the virtqueues, but nothing tells the device to stop first, so it is still live when the rings are freed.

Reset the device at out_cleanup_disk, which is only reachable after virtio_device_ready(). virtblk_remove() and virtblk_freeze_priv() both reset before deleting the virtqueues for the same reason.

Fixes dbb301f91fc8 ("virtio_blk: add error handling support for add_disk()")

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Yuho Choi
Quoted 9 lines · Yuho Choi

virtblk_probe() marks the device ready before revalidating zones and adding the disk, and either of those can fail. The out_cleanup_disk path they take goes on to delete the virtqueues, but nothing tells the device to stop first, so it is still live when the rings are freed.

Reset the device at out_cleanup_disk, which is only reachable after virtio_device_ready(). virtblk_remove() and virtblk_freeze_priv() both reset before deleting the virtqueues for the same reason.

Quoted 5 lines
Fixes dbb301f91fc8 ("virtio_blk: add error handling support for add_disk()")
---
 drivers/block/virtio_blk.c | 1 +
 1 file changed, 1 insertion(+)

Thanks for the fix!

Quoted 16 lines
drivers/block/virtio_blk.c +1 -0
index 32bf3ba07a9dc..ed97dafebe164 100644
@@ -1547,6 +1547,7 @@ static int virtblk_probe(struct virtio_device *vdev)
 	return 0;
 
 out_cleanup_disk:
+	virtio_reset_device(vdev);
 	put_disk(vblk->disk);
 out_free_tags:
 	blk_mq_free_tag_set(&vblk->tag_set);
Signature · 1 line
2.43.0