diff options
author | Asias He <asias@redhat.com> | 2013-04-23 16:33:52 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-04-25 04:21:22 -0400 |
commit | 6ad0b2f7fdfd95fe3107367f8aed252e94c3f654 (patch) | |
tree | 285c242b6faee9bea579b2c04d8e4b0a3deeba1a /net | |
parent | c6cdcf6d82bc8f53e64ad59464e0114fe48e28bb (diff) |
VSOCK: Fix misc device registration
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>
Diffstat (limited to 'net')
-rw-r--r-- | net/vmw_vsock/af_vsock.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index 7f93e2a42d7a..4b4db18ba92c 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 = { | |||
1932 | 1932 | ||
1933 | static struct miscdevice vsock_device = { | 1933 | static struct miscdevice vsock_device = { |
1934 | .name = "vsock", | 1934 | .name = "vsock", |
1935 | .minor = MISC_DYNAMIC_MINOR, | ||
1936 | .fops = &vsock_device_ops, | 1935 | .fops = &vsock_device_ops, |
1937 | }; | 1936 | }; |
1938 | 1937 | ||
@@ -1942,6 +1941,7 @@ static int __vsock_core_init(void) | |||
1942 | 1941 | ||
1943 | vsock_init_tables(); | 1942 | vsock_init_tables(); |
1944 | 1943 | ||
1944 | vsock_device.minor = MISC_DYNAMIC_MINOR; | ||
1945 | err = misc_register(&vsock_device); | 1945 | err = misc_register(&vsock_device); |
1946 | if (err) { | 1946 | if (err) { |
1947 | pr_err("Failed to register misc device\n"); | 1947 | pr_err("Failed to register misc device\n"); |