diff options
author | David S. Miller <davem@davemloft.net> | 2017-09-23 10:16:53 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-09-23 10:16:53 -0700 |
commit | 1f8d31d189cc6ce1e4b972959fda41e790bb92b8 (patch) | |
tree | fd3cca12a29319f073773ac55f7d41cc58e2c73f /net/packet | |
parent | 3fb5ec06578e4c85d3486b6a73cbeb07960a51ce (diff) | |
parent | cd4175b11685b11c40e31a03e05084cc212b0649 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Diffstat (limited to 'net/packet')
-rw-r--r-- | net/packet/af_packet.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index c26172995511..d288f52c53f7 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -1684,10 +1684,6 @@ static int fanout_add(struct sock *sk, u16 id, u16 type_flags) mutex_lock(&fanout_mutex); - err = -EINVAL; - if (!po->running) - goto out; - err = -EALREADY; if (po->fanout) goto out; @@ -1749,7 +1745,10 @@ static int fanout_add(struct sock *sk, u16 id, u16 type_flags) list_add(&match->list, &fanout_list); } err = -EINVAL; - if (match->type == type && + + spin_lock(&po->bind_lock); + if (po->running && + match->type == type && match->prot_hook.type == po->prot_hook.type && match->prot_hook.dev == po->prot_hook.dev) { err = -ENOSPC; @@ -1761,6 +1760,13 @@ static int fanout_add(struct sock *sk, u16 id, u16 type_flags) err = 0; } } + spin_unlock(&po->bind_lock); + + if (err && !refcount_read(&match->sk_ref)) { + list_del(&match->list); + kfree(match); + } + out: if (err && rollover) { kfree(rollover); |