diff options
Diffstat (limited to 'net/core/sock.c')
| -rw-r--r-- | net/core/sock.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/net/core/sock.c b/net/core/sock.c index e1f6f225f012..fcd397a762ff 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
| @@ -741,7 +741,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname, | |||
| 741 | struct timeval tm; | 741 | struct timeval tm; |
| 742 | } v; | 742 | } v; |
| 743 | 743 | ||
| 744 | unsigned int lv = sizeof(int); | 744 | int lv = sizeof(int); |
| 745 | int len; | 745 | int len; |
| 746 | 746 | ||
| 747 | if (get_user(len, optlen)) | 747 | if (get_user(len, optlen)) |
| @@ -1073,7 +1073,8 @@ static void __sk_free(struct sock *sk) | |||
| 1073 | if (sk->sk_destruct) | 1073 | if (sk->sk_destruct) |
| 1074 | sk->sk_destruct(sk); | 1074 | sk->sk_destruct(sk); |
| 1075 | 1075 | ||
| 1076 | filter = rcu_dereference(sk->sk_filter); | 1076 | filter = rcu_dereference_check(sk->sk_filter, |
| 1077 | atomic_read(&sk->sk_wmem_alloc) == 0); | ||
| 1077 | if (filter) { | 1078 | if (filter) { |
| 1078 | sk_filter_uncharge(sk, filter); | 1079 | sk_filter_uncharge(sk, filter); |
| 1079 | rcu_assign_pointer(sk->sk_filter, NULL); | 1080 | rcu_assign_pointer(sk->sk_filter, NULL); |
| @@ -2140,13 +2141,13 @@ int sock_prot_inuse_get(struct net *net, struct proto *prot) | |||
| 2140 | } | 2141 | } |
| 2141 | EXPORT_SYMBOL_GPL(sock_prot_inuse_get); | 2142 | EXPORT_SYMBOL_GPL(sock_prot_inuse_get); |
| 2142 | 2143 | ||
| 2143 | static int sock_inuse_init_net(struct net *net) | 2144 | static int __net_init sock_inuse_init_net(struct net *net) |
| 2144 | { | 2145 | { |
| 2145 | net->core.inuse = alloc_percpu(struct prot_inuse); | 2146 | net->core.inuse = alloc_percpu(struct prot_inuse); |
| 2146 | return net->core.inuse ? 0 : -ENOMEM; | 2147 | return net->core.inuse ? 0 : -ENOMEM; |
| 2147 | } | 2148 | } |
| 2148 | 2149 | ||
| 2149 | static void sock_inuse_exit_net(struct net *net) | 2150 | static void __net_exit sock_inuse_exit_net(struct net *net) |
| 2150 | { | 2151 | { |
| 2151 | free_percpu(net->core.inuse); | 2152 | free_percpu(net->core.inuse); |
| 2152 | } | 2153 | } |
| @@ -2228,13 +2229,10 @@ int proto_register(struct proto *prot, int alloc_slab) | |||
| 2228 | } | 2229 | } |
| 2229 | 2230 | ||
| 2230 | if (prot->rsk_prot != NULL) { | 2231 | if (prot->rsk_prot != NULL) { |
| 2231 | static const char mask[] = "request_sock_%s"; | 2232 | prot->rsk_prot->slab_name = kasprintf(GFP_KERNEL, "request_sock_%s", prot->name); |
| 2232 | |||
| 2233 | prot->rsk_prot->slab_name = kmalloc(strlen(prot->name) + sizeof(mask) - 1, GFP_KERNEL); | ||
| 2234 | if (prot->rsk_prot->slab_name == NULL) | 2233 | if (prot->rsk_prot->slab_name == NULL) |
| 2235 | goto out_free_sock_slab; | 2234 | goto out_free_sock_slab; |
| 2236 | 2235 | ||
| 2237 | sprintf(prot->rsk_prot->slab_name, mask, prot->name); | ||
| 2238 | prot->rsk_prot->slab = kmem_cache_create(prot->rsk_prot->slab_name, | 2236 | prot->rsk_prot->slab = kmem_cache_create(prot->rsk_prot->slab_name, |
| 2239 | prot->rsk_prot->obj_size, 0, | 2237 | prot->rsk_prot->obj_size, 0, |
| 2240 | SLAB_HWCACHE_ALIGN, NULL); | 2238 | SLAB_HWCACHE_ALIGN, NULL); |
| @@ -2247,14 +2245,11 @@ int proto_register(struct proto *prot, int alloc_slab) | |||
| 2247 | } | 2245 | } |
| 2248 | 2246 | ||
| 2249 | if (prot->twsk_prot != NULL) { | 2247 | if (prot->twsk_prot != NULL) { |
| 2250 | static const char mask[] = "tw_sock_%s"; | 2248 | prot->twsk_prot->twsk_slab_name = kasprintf(GFP_KERNEL, "tw_sock_%s", prot->name); |
| 2251 | |||
| 2252 | prot->twsk_prot->twsk_slab_name = kmalloc(strlen(prot->name) + sizeof(mask) - 1, GFP_KERNEL); | ||
| 2253 | 2249 | ||
| 2254 | if (prot->twsk_prot->twsk_slab_name == NULL) | 2250 | if (prot->twsk_prot->twsk_slab_name == NULL) |
| 2255 | goto out_free_request_sock_slab; | 2251 | goto out_free_request_sock_slab; |
| 2256 | 2252 | ||
| 2257 | sprintf(prot->twsk_prot->twsk_slab_name, mask, prot->name); | ||
| 2258 | prot->twsk_prot->twsk_slab = | 2253 | prot->twsk_prot->twsk_slab = |
| 2259 | kmem_cache_create(prot->twsk_prot->twsk_slab_name, | 2254 | kmem_cache_create(prot->twsk_prot->twsk_slab_name, |
| 2260 | prot->twsk_prot->twsk_obj_size, | 2255 | prot->twsk_prot->twsk_obj_size, |
