virtio_blk: fix race at module removal
Subsystems (3)
Michael S. Tsirkin
maintainerPATCH 1/1 virtio_blk: fix race at module removal
If a device appears while module is being removed, driver will get a callback after we've given up on the major number.
In theory this means this major number can get reused by something else, resulting in a conflict.
To fix, cleanup in reverse order of initialization.
--- drivers/block/virtio_blk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/virtio_blk.c +1 -1
@@ -883,8 +883,8 @@ out_destroy_workqueue: static void __exit fini(void) { -unregister_blkdev (major,"virtblk" );unregister_virtio_driver (&virtio_blk); +unregister_blkdev (major,"virtblk" );destroy_workqueue (virtblk_wq); }module_init (init);
Signature · 1 line
MST
Quoted 6 lines · Michael S. Tsirkin
If a device appears while module is being removed, driver will get a callback after we've given up on the major number.
In theory this means this major number can get reused by something else, resulting in a conflict.
Yes, there is a tiny race window.
Quoted 2 lines
To fix, cleanup in reverse order of initialization.
Quoted 10 lines
Signed-off-by Michael S. Tsirkin <[email protected]>--- drivers/block/virtio_blk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/block/virtio_blk.c +0
-0
drivers/block/virtio_blk.c out_destroy_workqueue: · line 890
Quoted 9 lines
drivers/block/virtio_blk.c +1
-1@@ -883,8 +883,8 @@ out_destroy_workqueue: static void __exit fini(void) { -unregister_blkdev (major,"virtblk" );unregister_virtio_driver (&virtio_blk); +unregister_blkdev (major,"virtblk" );destroy_workqueue (virtblk_wq); }module_init (init);
Thanks,
Signature · 1 line
Ming Lei
Rusty Russell
AppliedQuoted 9 lines · Ming Lei
Quoted 6 lines · Michael S. Tsirkin
If a device appears while module is being removed, driver will get a callback after we've given up on the major number.
In theory this means this major number can get reused by something else, resulting in a conflict.
Yes, there is a tiny race window.
Applied.
Thanks,
Rusty.