can: restart device even if dev_alloc_skb() fails
authorWolfgang Grandegger <wg@grandegger.com>
Mon, 20 Jul 2009 04:06:40 +0000 (04:06 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 20 Jul 2009 19:28:29 +0000 (12:28 -0700)
If dev_alloc_skb() failed in can_restart(), the device was left behind
in the bus-off state. This patch restarts the device nevertheless.

Signed-off-by: Kurt Van Dijck <kurt.van.dijck@eia.be>
Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/can/dev.c

index 574daddc21bfb02817fb3b49cfe5dec624936f8e..06083c32869a14b0c18aece6a88d3dbeb43f6db3 100644 (file)
@@ -346,7 +346,7 @@ void can_restart(unsigned long data)
        skb = dev_alloc_skb(sizeof(struct can_frame));
        if (skb == NULL) {
                err = -ENOMEM;
-               goto out;
+               goto restart;
        }
        skb->dev = dev;
        skb->protocol = htons(ETH_P_CAN);
@@ -361,13 +361,13 @@ void can_restart(unsigned long data)
        stats->rx_packets++;
        stats->rx_bytes += cf->can_dlc;
 
+restart:
        dev_dbg(dev->dev.parent, "restarted\n");
        priv->can_stats.restarts++;
 
        /* Now restart the device */
        err = priv->do_set_mode(dev, CAN_MODE_START);
 
-out:
        netif_carrier_on(dev);
        if (err)
                dev_err(dev->dev.parent, "Error %d during restart", err);