Skip to content

Commit

Permalink
VSOCK: Fix misc device registration
Browse files Browse the repository at this point in the history
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>
Acked-by: Dmitry Torokhov <dtor@vmware.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Asias He authored and David S. Miller committed Apr 25, 2013
1 parent c6cdcf6 commit 6ad0b2f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/vmw_vsock/af_vsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand All @@ -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");
Expand Down

0 comments on commit 6ad0b2f

Please sign in to comment.