cxgb4vf: recover from failure in cxgb4vf_open()
authorCasey Leedom <leedom@chelsio.com>
Tue, 11 Jan 2011 23:44:40 +0000 (15:44 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 11 Jan 2011 23:44:40 +0000 (15:44 -0800)
If the Link Start fails in cxgb4vf_open(), we need to back out any state
that we've built up ...

Signed-off-by: Casey Leedom <leedom@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/cxgb4vf/cxgb4vf_main.c

index 3c403f895750d90638d11d51ee34e0b52c22ef10..56166ae2059f3eb209ddf457bf2c8794d8f81d79 100644 (file)
@@ -749,13 +749,19 @@ static int cxgb4vf_open(struct net_device *dev)
        netif_set_real_num_tx_queues(dev, pi->nqsets);
        err = netif_set_real_num_rx_queues(dev, pi->nqsets);
        if (err)
-               return err;
-       set_bit(pi->port_id, &adapter->open_device_map);
+               goto err_unwind;
        err = link_start(dev);
        if (err)
-               return err;
+               goto err_unwind;
+
        netif_tx_start_all_queues(dev);
+       set_bit(pi->port_id, &adapter->open_device_map);
        return 0;
+
+err_unwind:
+       if (adapter->open_device_map == 0)
+               adapter_down(adapter);
+       return err;
 }
 
 /*
@@ -764,13 +770,12 @@ static int cxgb4vf_open(struct net_device *dev)
  */
 static int cxgb4vf_stop(struct net_device *dev)
 {
-       int ret;
        struct port_info *pi = netdev_priv(dev);
        struct adapter *adapter = pi->adapter;
 
        netif_tx_stop_all_queues(dev);
        netif_carrier_off(dev);
-       ret = t4vf_enable_vi(adapter, pi->viid, false, false);
+       t4vf_enable_vi(adapter, pi->viid, false, false);
        pi->link_cfg.link_ok = 0;
 
        clear_bit(pi->port_id, &adapter->open_device_map);