From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757290Ab3DXPqe (ORCPT ); Wed, 24 Apr 2013 11:46:34 -0400 Received: from smtp-outbound-2.vmware.com ([208.91.2.13]:46883 "EHLO smtp-outbound-2.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756199Ab3DXPqd (ORCPT ); Wed, 24 Apr 2013 11:46:33 -0400 X-Greylist: delayed 494 seconds by postgrey-1.27 at vger.kernel.org; Wed, 24 Apr 2013 11:46:33 EDT Date: Wed, 24 Apr 2013 08:38:18 -0700 From: Dmitry Torokhov To: Asias He Cc: netdev@vger.kernel.org, "David S. Miller" , Andy King , Reilly Grant , linux-kernel@vger.kernel.org Subject: Re: [PATCH] VSOCK: Fix misc device registration Message-ID: <20130424153818.GA6916@dtor-ws.eng.vmware.com> References: <1366785232-15653-1-git-send-email-asias@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1366785232-15653-1-git-send-email-asias@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 24, 2013 at 02:33:52PM +0800, Asias He wrote: > When we call vsock_core_init to init VSOCK the second time, > vsock_device.minor still points to the old dynamically allocated minor > number. misc_register will allocate it for us successfully as if we were > asking for a static one. However, when other user call misc_register to > allocate a dynamic minor number, it will give the one used by > vsock_core_init(), causing this: > > [ 405.470687] WARNING: at fs/sysfs/dir.c:536 sysfs_add_one+0xcc/0xf0() > [ 405.470689] Hardware name: OptiPlex 790 > [ 405.470690] sysfs: cannot create duplicate filename '/dev/char/10:54' > > Always set vsock_device.minor to MISC_DYNAMIC_MINOR before we > register. > > Cc: "David S. Miller" > Cc: Andy King > Cc: Dmitry Torokhov > Cc: Reilly Grant > Cc: netdev@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Asias He Well spotted. Acked-by: Dmitry Torokhov > --- > net/vmw_vsock/af_vsock.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c > index 7f93e2a..4b4db18 100644 > --- a/net/vmw_vsock/af_vsock.c > +++ b/net/vmw_vsock/af_vsock.c > @@ -1932,7 +1932,6 @@ static const struct file_operations vsock_device_ops = { > > static struct miscdevice vsock_device = { > .name = "vsock", > - .minor = MISC_DYNAMIC_MINOR, > .fops = &vsock_device_ops, > }; > > @@ -1942,6 +1941,7 @@ static int __vsock_core_init(void) > > vsock_init_tables(); > > + vsock_device.minor = MISC_DYNAMIC_MINOR; > err = misc_register(&vsock_device); > if (err) { > pr_err("Failed to register misc device\n"); > -- > 1.8.1.4