From 72570ff1d3499a7b05c78b7a9a15d4aec92dcd3f Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Mon, 6 Oct 2003 12:40:33 -0700 Subject: [PATCH] [BPQETHER]: Fix packet handler to be PKT_CAN_SHARE_SKB. --- drivers/net/hamradio/bpqether.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c index 03673c480d433..107ff6a6431ea 100644 --- a/drivers/net/hamradio/bpqether.c +++ b/drivers/net/hamradio/bpqether.c @@ -105,6 +105,7 @@ static const char *bpq_print_ethaddr(const unsigned char *); static struct packet_type bpq_packet_type = { .type = __constant_htons(ETH_P_BPQ), .func = bpq_rcv, + .data = PKT_CAN_SHARE_SKB, }; static struct notifier_block bpq_dev_notifier = { @@ -171,16 +172,17 @@ static int bpq_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_ty { int len; char * ptr; - struct ethhdr *eth = (struct ethhdr *)skb->mac.raw; + struct ethhdr *eth; struct bpqdev *bpq; - skb->sk = NULL; /* Initially we don't know who it's for */ + if (!pskb_may_pull(skb, sizeof(struct ethhdr))) + goto drop; rcu_read_lock(); dev = bpq_get_ax25_dev(dev); if (dev == NULL || !netif_running(dev)) - goto drop; + goto drop_unlock; /* * if we want to accept frames from just one ethernet device @@ -189,11 +191,19 @@ static int bpq_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_ty bpq = (struct bpqdev *)dev->priv; - if (!(bpq->acpt_addr[0] & 0x01) && memcmp(eth->h_source, bpq->acpt_addr, ETH_ALEN)) { - printk(KERN_DEBUG "bpqether: wrong dest %s\n", bpq_print_ethaddr(eth->h_source)); - goto drop; + eth = (struct ethhdr *)skb->mac.raw; + + if (!(bpq->acpt_addr[0] & 0x01) && + memcmp(eth->h_source, bpq->acpt_addr, ETH_ALEN)) { + if (net_ratelimit()) + printk(KERN_DEBUG "bpqether: wrong dest %s\n", + bpq_print_ethaddr(eth->h_source)); + goto drop_unlock; } + if (skb_cow(skb, sizeof(struct ethhdr))) + goto drop_unlock; + len = skb->data[0] + skb->data[1] * 256 - 5; skb_pull(skb, 2); /* Remove the length bytes */ @@ -212,15 +222,18 @@ static int bpq_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_ty netif_rx(skb); dev->last_rx = jiffies; - unlock: +unlock: rcu_read_unlock(); return 0; - drop: +drop_unlock: kfree_skb(skb); goto unlock; +drop: + kfree_skb(skb); + return 0; } /* -- 2.53.0