diff options
Diffstat (limited to 'net/core/sock.c')
-rw-r--r-- | net/core/sock.c | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/net/core/sock.c b/net/core/sock.c index 5e2a3132a8c9..edf7220889a4 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -136,7 +136,6 @@ | |||
136 | static struct lock_class_key af_family_keys[AF_MAX]; | 136 | static struct lock_class_key af_family_keys[AF_MAX]; |
137 | static struct lock_class_key af_family_slock_keys[AF_MAX]; | 137 | static struct lock_class_key af_family_slock_keys[AF_MAX]; |
138 | 138 | ||
139 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
140 | /* | 139 | /* |
141 | * Make lock validator output more readable. (we pre-construct these | 140 | * Make lock validator output more readable. (we pre-construct these |
142 | * strings build-time, so that runtime initialization of socket | 141 | * strings build-time, so that runtime initialization of socket |
@@ -187,7 +186,6 @@ static const char *af_family_clock_key_strings[AF_MAX+1] = { | |||
187 | "clock-AF_RXRPC" , "clock-AF_ISDN" , "clock-AF_PHONET" , | 186 | "clock-AF_RXRPC" , "clock-AF_ISDN" , "clock-AF_PHONET" , |
188 | "clock-AF_MAX" | 187 | "clock-AF_MAX" |
189 | }; | 188 | }; |
190 | #endif | ||
191 | 189 | ||
192 | /* | 190 | /* |
193 | * sk_callback_lock locking rules are per-address-family, | 191 | * sk_callback_lock locking rules are per-address-family, |
@@ -2037,9 +2035,6 @@ static inline void release_proto_idx(struct proto *prot) | |||
2037 | 2035 | ||
2038 | int proto_register(struct proto *prot, int alloc_slab) | 2036 | int proto_register(struct proto *prot, int alloc_slab) |
2039 | { | 2037 | { |
2040 | char *request_sock_slab_name = NULL; | ||
2041 | char *timewait_sock_slab_name; | ||
2042 | |||
2043 | if (alloc_slab) { | 2038 | if (alloc_slab) { |
2044 | prot->slab = kmem_cache_create(prot->name, prot->obj_size, 0, | 2039 | prot->slab = kmem_cache_create(prot->name, prot->obj_size, 0, |
2045 | SLAB_HWCACHE_ALIGN, NULL); | 2040 | SLAB_HWCACHE_ALIGN, NULL); |
@@ -2053,12 +2048,12 @@ int proto_register(struct proto *prot, int alloc_slab) | |||
2053 | if (prot->rsk_prot != NULL) { | 2048 | if (prot->rsk_prot != NULL) { |
2054 | static const char mask[] = "request_sock_%s"; | 2049 | static const char mask[] = "request_sock_%s"; |
2055 | 2050 | ||
2056 | request_sock_slab_name = kmalloc(strlen(prot->name) + sizeof(mask) - 1, GFP_KERNEL); | 2051 | prot->rsk_prot->slab_name = kmalloc(strlen(prot->name) + sizeof(mask) - 1, GFP_KERNEL); |
2057 | if (request_sock_slab_name == NULL) | 2052 | if (prot->rsk_prot->slab_name == NULL) |
2058 | goto out_free_sock_slab; | 2053 | goto out_free_sock_slab; |
2059 | 2054 | ||
2060 | sprintf(request_sock_slab_name, mask, prot->name); | 2055 | sprintf(prot->rsk_prot->slab_name, mask, prot->name); |
2061 | prot->rsk_prot->slab = kmem_cache_create(request_sock_slab_name, | 2056 | prot->rsk_prot->slab = kmem_cache_create(prot->rsk_prot->slab_name, |
2062 | prot->rsk_prot->obj_size, 0, | 2057 | prot->rsk_prot->obj_size, 0, |
2063 | SLAB_HWCACHE_ALIGN, NULL); | 2058 | SLAB_HWCACHE_ALIGN, NULL); |
2064 | 2059 | ||
@@ -2072,14 +2067,14 @@ int proto_register(struct proto *prot, int alloc_slab) | |||
2072 | if (prot->twsk_prot != NULL) { | 2067 | if (prot->twsk_prot != NULL) { |
2073 | static const char mask[] = "tw_sock_%s"; | 2068 | static const char mask[] = "tw_sock_%s"; |
2074 | 2069 | ||
2075 | timewait_sock_slab_name = kmalloc(strlen(prot->name) + sizeof(mask) - 1, GFP_KERNEL); | 2070 | prot->twsk_prot->twsk_slab_name = kmalloc(strlen(prot->name) + sizeof(mask) - 1, GFP_KERNEL); |
2076 | 2071 | ||
2077 | if (timewait_sock_slab_name == NULL) | 2072 | if (prot->twsk_prot->twsk_slab_name == NULL) |
2078 | goto out_free_request_sock_slab; | 2073 | goto out_free_request_sock_slab; |
2079 | 2074 | ||
2080 | sprintf(timewait_sock_slab_name, mask, prot->name); | 2075 | sprintf(prot->twsk_prot->twsk_slab_name, mask, prot->name); |
2081 | prot->twsk_prot->twsk_slab = | 2076 | prot->twsk_prot->twsk_slab = |
2082 | kmem_cache_create(timewait_sock_slab_name, | 2077 | kmem_cache_create(prot->twsk_prot->twsk_slab_name, |
2083 | prot->twsk_prot->twsk_obj_size, | 2078 | prot->twsk_prot->twsk_obj_size, |
2084 | 0, SLAB_HWCACHE_ALIGN, | 2079 | 0, SLAB_HWCACHE_ALIGN, |
2085 | NULL); | 2080 | NULL); |
@@ -2095,14 +2090,14 @@ int proto_register(struct proto *prot, int alloc_slab) | |||
2095 | return 0; | 2090 | return 0; |
2096 | 2091 | ||
2097 | out_free_timewait_sock_slab_name: | 2092 | out_free_timewait_sock_slab_name: |
2098 | kfree(timewait_sock_slab_name); | 2093 | kfree(prot->twsk_prot->twsk_slab_name); |
2099 | out_free_request_sock_slab: | 2094 | out_free_request_sock_slab: |
2100 | if (prot->rsk_prot && prot->rsk_prot->slab) { | 2095 | if (prot->rsk_prot && prot->rsk_prot->slab) { |
2101 | kmem_cache_destroy(prot->rsk_prot->slab); | 2096 | kmem_cache_destroy(prot->rsk_prot->slab); |
2102 | prot->rsk_prot->slab = NULL; | 2097 | prot->rsk_prot->slab = NULL; |
2103 | } | 2098 | } |
2104 | out_free_request_sock_slab_name: | 2099 | out_free_request_sock_slab_name: |
2105 | kfree(request_sock_slab_name); | 2100 | kfree(prot->rsk_prot->slab_name); |
2106 | out_free_sock_slab: | 2101 | out_free_sock_slab: |
2107 | kmem_cache_destroy(prot->slab); | 2102 | kmem_cache_destroy(prot->slab); |
2108 | prot->slab = NULL; | 2103 | prot->slab = NULL; |
@@ -2125,18 +2120,14 @@ void proto_unregister(struct proto *prot) | |||
2125 | } | 2120 | } |
2126 | 2121 | ||
2127 | if (prot->rsk_prot != NULL && prot->rsk_prot->slab != NULL) { | 2122 | if (prot->rsk_prot != NULL && prot->rsk_prot->slab != NULL) { |
2128 | const char *name = kmem_cache_name(prot->rsk_prot->slab); | ||
2129 | |||
2130 | kmem_cache_destroy(prot->rsk_prot->slab); | 2123 | kmem_cache_destroy(prot->rsk_prot->slab); |
2131 | kfree(name); | 2124 | kfree(prot->rsk_prot->slab_name); |
2132 | prot->rsk_prot->slab = NULL; | 2125 | prot->rsk_prot->slab = NULL; |
2133 | } | 2126 | } |
2134 | 2127 | ||
2135 | if (prot->twsk_prot != NULL && prot->twsk_prot->twsk_slab != NULL) { | 2128 | if (prot->twsk_prot != NULL && prot->twsk_prot->twsk_slab != NULL) { |
2136 | const char *name = kmem_cache_name(prot->twsk_prot->twsk_slab); | ||
2137 | |||
2138 | kmem_cache_destroy(prot->twsk_prot->twsk_slab); | 2129 | kmem_cache_destroy(prot->twsk_prot->twsk_slab); |
2139 | kfree(name); | 2130 | kfree(prot->twsk_prot->twsk_slab_name); |
2140 | prot->twsk_prot->twsk_slab = NULL; | 2131 | prot->twsk_prot->twsk_slab = NULL; |
2141 | } | 2132 | } |
2142 | } | 2133 | } |