netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] VSOCK: Fix misc device registration
@ 2013-04-24  6:33 Asias He
  2013-04-24 15:38 ` Dmitry Torokhov
  2013-04-25  8:22 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Asias He @ 2013-04-24  6:33 UTC (permalink / raw)
  To: netdev
  Cc: Asias He, David S. Miller, Andy King, Dmitry Torokhov,
	Reilly Grant, linux-kernel

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" <davem@davemloft.net>
Cc: Andy King <acking@vmware.com>
Cc: Dmitry Torokhov <dtor@vmware.com>
Cc: Reilly Grant <grantr@vmware.com>
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Asias He <asias@redhat.com>
---
 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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] VSOCK: Fix misc device registration
  2013-04-24  6:33 [PATCH] VSOCK: Fix misc device registration Asias He
@ 2013-04-24 15:38 ` Dmitry Torokhov
  2013-04-25  8:22 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2013-04-24 15:38 UTC (permalink / raw)
  To: Asias He; +Cc: netdev, David S. Miller, Andy King, Reilly Grant, linux-kernel

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" <davem@davemloft.net>
> Cc: Andy King <acking@vmware.com>
> Cc: Dmitry Torokhov <dtor@vmware.com>
> Cc: Reilly Grant <grantr@vmware.com>
> Cc: netdev@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Asias He <asias@redhat.com>

Well spotted.

Acked-by: Dmitry Torokhov <dtor@vmware.com>

> ---
>  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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] VSOCK: Fix misc device registration
  2013-04-24  6:33 [PATCH] VSOCK: Fix misc device registration Asias He
  2013-04-24 15:38 ` Dmitry Torokhov
@ 2013-04-25  8:22 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2013-04-25  8:22 UTC (permalink / raw)
  To: asias; +Cc: netdev, acking, dtor, grantr, linux-kernel

From: Asias He <asias@redhat.com>
Date: Wed, 24 Apr 2013 14:33:52 +0800

> 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" <davem@davemloft.net>
> Cc: Andy King <acking@vmware.com>
> Cc: Dmitry Torokhov <dtor@vmware.com>
> Cc: Reilly Grant <grantr@vmware.com>
> Cc: netdev@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Asias He <asias@redhat.com>

Applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-04-25  8:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-24  6:33 [PATCH] VSOCK: Fix misc device registration Asias He
2013-04-24 15:38 ` Dmitry Torokhov
2013-04-25  8:22 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).