Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755025AbaJXCNF (ORCPT ); Thu, 23 Oct 2014 22:13:05 -0400 Received: from mail-yh0-f42.google.com ([209.85.213.42]:42944 "EHLO mail-yh0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751700AbaJXCND (ORCPT ); Thu, 23 Oct 2014 22:13:03 -0400 MIME-Version: 1.0 In-Reply-To: <1414080703-4547-1-git-send-email-mst@redhat.com> References: <1414080703-4547-1-git-send-email-mst@redhat.com> Date: Fri, 24 Oct 2014 10:13:01 +0800 Message-ID: Subject: Re: [PATCH] virtio_blk: fix race at module removal From: Ming Lei To: "Michael S. Tsirkin" Cc: Linux Kernel Mailing List , Rusty Russell , Linux Virtualization Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 24, 2014 at 12:12 AM, Michael S. Tsirkin wrote: > 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. > > To fix, cleanup in reverse order of initialization. Reviewed-by: Ming Lei > Signed-off-by: Michael S. Tsirkin > --- > 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 56aadbc..adfba9f 100644 > --- a/drivers/block/virtio_blk.c > +++ b/drivers/block/virtio_blk.c > @@ -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, -- Ming Lei -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/