diff options
Diffstat (limited to 'kernel/bpf/sockmap.c')
-rw-r--r-- | kernel/bpf/sockmap.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c index 98e621a29e8e..cf5195c7c331 100644 --- a/kernel/bpf/sockmap.c +++ b/kernel/bpf/sockmap.c | |||
@@ -1427,12 +1427,15 @@ out: | |||
1427 | static void smap_write_space(struct sock *sk) | 1427 | static void smap_write_space(struct sock *sk) |
1428 | { | 1428 | { |
1429 | struct smap_psock *psock; | 1429 | struct smap_psock *psock; |
1430 | void (*write_space)(struct sock *sk); | ||
1430 | 1431 | ||
1431 | rcu_read_lock(); | 1432 | rcu_read_lock(); |
1432 | psock = smap_psock_sk(sk); | 1433 | psock = smap_psock_sk(sk); |
1433 | if (likely(psock && test_bit(SMAP_TX_RUNNING, &psock->state))) | 1434 | if (likely(psock && test_bit(SMAP_TX_RUNNING, &psock->state))) |
1434 | schedule_work(&psock->tx_work); | 1435 | schedule_work(&psock->tx_work); |
1436 | write_space = psock->save_write_space; | ||
1435 | rcu_read_unlock(); | 1437 | rcu_read_unlock(); |
1438 | write_space(sk); | ||
1436 | } | 1439 | } |
1437 | 1440 | ||
1438 | static void smap_stop_sock(struct smap_psock *psock, struct sock *sk) | 1441 | static void smap_stop_sock(struct smap_psock *psock, struct sock *sk) |
@@ -2140,7 +2143,9 @@ static struct bpf_map *sock_hash_alloc(union bpf_attr *attr) | |||
2140 | return ERR_PTR(-EPERM); | 2143 | return ERR_PTR(-EPERM); |
2141 | 2144 | ||
2142 | /* check sanity of attributes */ | 2145 | /* check sanity of attributes */ |
2143 | if (attr->max_entries == 0 || attr->value_size != 4 || | 2146 | if (attr->max_entries == 0 || |
2147 | attr->key_size == 0 || | ||
2148 | attr->value_size != 4 || | ||
2144 | attr->map_flags & ~SOCK_CREATE_FLAG_MASK) | 2149 | attr->map_flags & ~SOCK_CREATE_FLAG_MASK) |
2145 | return ERR_PTR(-EINVAL); | 2150 | return ERR_PTR(-EINVAL); |
2146 | 2151 | ||
@@ -2267,8 +2272,10 @@ static struct htab_elem *alloc_sock_hash_elem(struct bpf_htab *htab, | |||
2267 | } | 2272 | } |
2268 | l_new = kmalloc_node(htab->elem_size, GFP_ATOMIC | __GFP_NOWARN, | 2273 | l_new = kmalloc_node(htab->elem_size, GFP_ATOMIC | __GFP_NOWARN, |
2269 | htab->map.numa_node); | 2274 | htab->map.numa_node); |
2270 | if (!l_new) | 2275 | if (!l_new) { |
2276 | atomic_dec(&htab->count); | ||
2271 | return ERR_PTR(-ENOMEM); | 2277 | return ERR_PTR(-ENOMEM); |
2278 | } | ||
2272 | 2279 | ||
2273 | memcpy(l_new->key, key, key_size); | 2280 | memcpy(l_new->key, key, key_size); |
2274 | l_new->sk = sk; | 2281 | l_new->sk = sk; |