Merge git://git.infradead.org/~dwmw2/random-2.6
[pandora-kernel.git] / net / 802 / psnap.c
index 7cba1f4..b3cfe5a 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/mm.h>
 #include <linux/in.h>
 #include <linux/init.h>
+#include <linux/rculist.h>
 
 static LIST_HEAD(snap_list);
 static DEFINE_SPINLOCK(snap_lock);
@@ -30,11 +31,9 @@ static struct llc_sap *snap_sap;
  */
 static struct datalink_proto *find_snap_client(unsigned char *desc)
 {
-       struct list_head *entry;
        struct datalink_proto *proto = NULL, *p;
 
-       list_for_each_rcu(entry, &snap_list) {
-               p = list_entry(entry, struct datalink_proto, node);
+       list_for_each_entry_rcu(p, &snap_list, node) {
                if (!memcmp(p->type, desc, 5)) {
                        proto = p;
                        break;
@@ -55,21 +54,28 @@ static int snap_rcv(struct sk_buff *skb, struct net_device *dev,
                .type = __constant_htons(ETH_P_SNAP),
        };
 
+       if (unlikely(!pskb_may_pull(skb, 5)))
+               goto drop;
+
        rcu_read_lock();
        proto = find_snap_client(skb_transport_header(skb));
        if (proto) {
                /* Pass the frame on. */
-               skb->h.raw  += 5;
+               skb->transport_header += 5;
                skb_pull_rcsum(skb, 5);
                rc = proto->rcvfunc(skb, dev, &snap_packet_type, orig_dev);
-       } else {
-               skb->sk = NULL;
-               kfree_skb(skb);
-               rc = 1;
        }
-
        rcu_read_unlock();
+
+       if (unlikely(!proto))
+               goto drop;
+
+out:
        return rc;
+
+drop:
+       kfree_skb(skb);
+       goto out;
 }
 
 /*