From: Michael S. Tsirkin Date: Sun, 9 Nov 2014 23:04:29 +0000 (+1030) Subject: virtio_blk: fix race at module removal X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=46652a861b46cc62e9d983d5cf6d9532cd6fccab;p=openwrt%2Fstaging%2Fblogic.git 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 --- 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);