virtio_blk: Reset device on probe error paths after DRIVER_OK
Subsystems (4)
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.
--- drivers/block/virtio_blk.c | 1 + 1 file changed, 1 insertion(+)
drivers/block/virtio_blk.c +1 -0
@@ -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
[email protected]
AI reviewSashiko 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. Theout_cleanup_diskpath 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 aftervirtio_device_ready().virtblk_remove()andvirtblk_freeze_priv()both reset before deleting the virtqueues for the same reason.Fixes dbb301f91fc8 ("virtio_blk: add error handling support for add_disk()")Signed-off-by Yuho Choi <[email protected]>
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
Quoted 9 lines · Yuho Choi
virtblk_probe()marks the device ready before revalidating zones and adding the disk, and either of those can fail. Theout_cleanup_diskpath 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 aftervirtio_device_ready().virtblk_remove()andvirtblk_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()")Signed-off-by Yuho Choi <[email protected]>--- 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@@ -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