diff options
Diffstat (limited to 'net/packet/af_packet.c')
-rw-r--r-- | net/packet/af_packet.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index c9e8741226c6..ed458b315ef4 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -2403,7 +2403,8 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg) | |||
2403 | } | 2403 | } |
2404 | tp_len = tpacket_fill_skb(po, skb, ph, dev, size_max, proto, | 2404 | tp_len = tpacket_fill_skb(po, skb, ph, dev, size_max, proto, |
2405 | addr, hlen); | 2405 | addr, hlen); |
2406 | if (tp_len > dev->mtu + dev->hard_header_len) { | 2406 | if (likely(tp_len >= 0) && |
2407 | tp_len > dev->mtu + dev->hard_header_len) { | ||
2407 | struct ethhdr *ehdr; | 2408 | struct ethhdr *ehdr; |
2408 | /* Earlier code assumed this would be a VLAN pkt, | 2409 | /* Earlier code assumed this would be a VLAN pkt, |
2409 | * double-check this now that we have the actual | 2410 | * double-check this now that we have the actual |
@@ -2784,7 +2785,7 @@ static int packet_release(struct socket *sock) | |||
2784 | static int packet_do_bind(struct sock *sk, struct net_device *dev, __be16 proto) | 2785 | static int packet_do_bind(struct sock *sk, struct net_device *dev, __be16 proto) |
2785 | { | 2786 | { |
2786 | struct packet_sock *po = pkt_sk(sk); | 2787 | struct packet_sock *po = pkt_sk(sk); |
2787 | const struct net_device *dev_curr; | 2788 | struct net_device *dev_curr; |
2788 | __be16 proto_curr; | 2789 | __be16 proto_curr; |
2789 | bool need_rehook; | 2790 | bool need_rehook; |
2790 | 2791 | ||
@@ -2808,15 +2809,13 @@ static int packet_do_bind(struct sock *sk, struct net_device *dev, __be16 proto) | |||
2808 | 2809 | ||
2809 | po->num = proto; | 2810 | po->num = proto; |
2810 | po->prot_hook.type = proto; | 2811 | po->prot_hook.type = proto; |
2811 | |||
2812 | if (po->prot_hook.dev) | ||
2813 | dev_put(po->prot_hook.dev); | ||
2814 | |||
2815 | po->prot_hook.dev = dev; | 2812 | po->prot_hook.dev = dev; |
2816 | 2813 | ||
2817 | po->ifindex = dev ? dev->ifindex : 0; | 2814 | po->ifindex = dev ? dev->ifindex : 0; |
2818 | packet_cached_dev_assign(po, dev); | 2815 | packet_cached_dev_assign(po, dev); |
2819 | } | 2816 | } |
2817 | if (dev_curr) | ||
2818 | dev_put(dev_curr); | ||
2820 | 2819 | ||
2821 | if (proto == 0 || !need_rehook) | 2820 | if (proto == 0 || !need_rehook) |
2822 | goto out_unlock; | 2821 | goto out_unlock; |