summaryrefslogtreecommitdiff
path: root/net/packet/af_packet.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2017-10-05 15:08:57 +0200
committerTakashi Iwai <tiwai@suse.de>2017-10-05 15:08:57 +0200
commit3a9fce327ff9cabf7f89d3f20616a83af28393da (patch)
treec516d3e7023e7fe2dc8d4cf60e2ec03f3c9b5958 /net/packet/af_packet.c
parente195a331c4124a6527e5e1b6fbd93a6b4a984d7b (diff)
parent394ca81cb4c1518e9463fe342fb1ae8a9f46a82d (diff)
Merge branch 'topic/timer-api' into for-next
Diffstat (limited to 'net/packet/af_packet.c')
-rw-r--r--net/packet/af_packet.c16
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);