From 46652a861b46cc62e9d983d5cf6d9532cd6fccab Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Mon, 10 Nov 2014 09:34:29 +1030 Subject: [PATCH] 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. Signed-off-by: Michael S. Tsirkin Reviewed-by: Ming Lei Signed-off-by: Rusty Russell --- drivers/block/virtio_blk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index c6a27d54ad62..ce848ac1e9a6 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -871,8 +871,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); -- 2.30.2