diff options
Diffstat (limited to 'net/vmw_vsock/af_vsock.c')
-rw-r--r-- | net/vmw_vsock/af_vsock.c | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index 5adfd94c5b85..85d232bed87d 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c | |||
@@ -1925,9 +1925,23 @@ static struct miscdevice vsock_device = { | |||
1925 | .fops = &vsock_device_ops, | 1925 | .fops = &vsock_device_ops, |
1926 | }; | 1926 | }; |
1927 | 1927 | ||
1928 | static int __vsock_core_init(void) | 1928 | int __vsock_core_init(const struct vsock_transport *t, struct module *owner) |
1929 | { | 1929 | { |
1930 | int err; | 1930 | int err = mutex_lock_interruptible(&vsock_register_mutex); |
1931 | |||
1932 | if (err) | ||
1933 | return err; | ||
1934 | |||
1935 | if (transport) { | ||
1936 | err = -EBUSY; | ||
1937 | goto err_busy; | ||
1938 | } | ||
1939 | |||
1940 | /* Transport must be the owner of the protocol so that it can't | ||
1941 | * unload while there are open sockets. | ||
1942 | */ | ||
1943 | vsock_proto.owner = owner; | ||
1944 | transport = t; | ||
1931 | 1945 | ||
1932 | vsock_init_tables(); | 1946 | vsock_init_tables(); |
1933 | 1947 | ||
@@ -1951,36 +1965,19 @@ static int __vsock_core_init(void) | |||
1951 | goto err_unregister_proto; | 1965 | goto err_unregister_proto; |
1952 | } | 1966 | } |
1953 | 1967 | ||
1968 | mutex_unlock(&vsock_register_mutex); | ||
1954 | return 0; | 1969 | return 0; |
1955 | 1970 | ||
1956 | err_unregister_proto: | 1971 | err_unregister_proto: |
1957 | proto_unregister(&vsock_proto); | 1972 | proto_unregister(&vsock_proto); |
1958 | err_misc_deregister: | 1973 | err_misc_deregister: |
1959 | misc_deregister(&vsock_device); | 1974 | misc_deregister(&vsock_device); |
1960 | return err; | 1975 | transport = NULL; |
1961 | } | 1976 | err_busy: |
1962 | |||
1963 | int vsock_core_init(const struct vsock_transport *t) | ||
1964 | { | ||
1965 | int retval = mutex_lock_interruptible(&vsock_register_mutex); | ||
1966 | if (retval) | ||
1967 | return retval; | ||
1968 | |||
1969 | if (transport) { | ||
1970 | retval = -EBUSY; | ||
1971 | goto out; | ||
1972 | } | ||
1973 | |||
1974 | transport = t; | ||
1975 | retval = __vsock_core_init(); | ||
1976 | if (retval) | ||
1977 | transport = NULL; | ||
1978 | |||
1979 | out: | ||
1980 | mutex_unlock(&vsock_register_mutex); | 1977 | mutex_unlock(&vsock_register_mutex); |
1981 | return retval; | 1978 | return err; |
1982 | } | 1979 | } |
1983 | EXPORT_SYMBOL_GPL(vsock_core_init); | 1980 | EXPORT_SYMBOL_GPL(__vsock_core_init); |
1984 | 1981 | ||
1985 | void vsock_core_exit(void) | 1982 | void vsock_core_exit(void) |
1986 | { | 1983 | { |
@@ -2000,5 +1997,5 @@ EXPORT_SYMBOL_GPL(vsock_core_exit); | |||
2000 | 1997 | ||
2001 | MODULE_AUTHOR("VMware, Inc."); | 1998 | MODULE_AUTHOR("VMware, Inc."); |
2002 | MODULE_DESCRIPTION("VMware Virtual Socket Family"); | 1999 | MODULE_DESCRIPTION("VMware Virtual Socket Family"); |
2003 | MODULE_VERSION("1.0.0.0-k"); | 2000 | MODULE_VERSION("1.0.1.0-k"); |
2004 | MODULE_LICENSE("GPL v2"); | 2001 | MODULE_LICENSE("GPL v2"); |