DivestOS/Patches/Linux_CVEs/CVE-2017-6346/3.18/1.patch
2017-10-29 22:14:37 -04:00

54 lines
1007 B
Diff

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 05cfee7..2ae5ae2 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1429,13 +1429,16 @@
return -EINVAL;
}
- if (!po->running)
- return -EINVAL;
-
- if (po->fanout)
- return -EALREADY;
-
mutex_lock(&fanout_mutex);
+
+ err = -EINVAL;
+ if (!po->running)
+ goto out;
+
+ err = -EALREADY;
+ if (po->fanout)
+ goto out;
+
match = NULL;
list_for_each_entry(f, &fanout_list, list) {
if (f->id == id &&
@@ -1491,17 +1494,16 @@
struct packet_sock *po = pkt_sk(sk);
struct packet_fanout *f;
- f = po->fanout;
- if (!f)
- return;
-
mutex_lock(&fanout_mutex);
- po->fanout = NULL;
+ f = po->fanout;
+ if (f) {
+ po->fanout = NULL;
- if (atomic_dec_and_test(&f->sk_ref)) {
- list_del(&f->list);
- dev_remove_pack(&f->prot_hook);
- kfree(f);
+ if (atomic_dec_and_test(&f->sk_ref)) {
+ list_del(&f->list);
+ dev_remove_pack(&f->prot_hook);
+ kfree(f);
+ }
}
mutex_unlock(&fanout_mutex);
}