wan/hdlc_x25.c: fix a NULL dereference
authorKrzysztof Halasa <khc@pm.waw.pl>
Wed, 3 Sep 2008 16:21:56 +0000 (18:21 +0200)
committerJeff Garzik <jgarzik@redhat.com>
Wed, 24 Sep 2008 22:49:02 +0000 (18:49 -0400)
WAN: fixes a NULL dereference in hdlc_x25.

Reported-by: Adrian Bunk <bunk@kernel.org>.
Signed-off-by: Krzysztof Halasa <khc@pm.waw.pl>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
drivers/net/wan/hdlc_x25.c

index 8b7e5d2e2ac94ced976d54587ba074142a13776a..cbcbf6f0414c9254aea1d14f95e7220b50ccab13 100644 (file)
@@ -163,15 +163,17 @@ static void x25_close(struct net_device *dev)
 
 static int x25_rx(struct sk_buff *skb)
 {
+       struct net_device *dev = skb->dev;
+
        if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) {
-               skb->dev->stats.rx_dropped++;
+               dev->stats.rx_dropped++;
                return NET_RX_DROP;
        }
 
-       if (lapb_data_received(skb->dev, skb) == LAPB_OK)
+       if (lapb_data_received(dev, skb) == LAPB_OK)
                return NET_RX_SUCCESS;
 
-       skb->dev->stats.rx_errors++;
+       dev->stats.rx_errors++;
        dev_kfree_skb_any(skb);
        return NET_RX_DROP;
 }