libertas: harden-up exit paths
authorDaniel Drake <dsd@laptop.org>
Mon, 16 Apr 2012 22:53:02 +0000 (23:53 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 17 Apr 2012 18:57:14 +0000 (14:57 -0400)
These simple sanity check avoids extra complexity in error paths when
moving to asynchronous firmware loading (which means the device may fail to
init some time after its creation).

Signed-off-by: Daniel Drake <dsd@laptop.org>
Acked-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/libertas/main.c

index fa095851f214cffe2bb64eea8bce3e089c291a6b..7eaf992775ae7e0e23d748685b7658e2121e65b4 100644 (file)
@@ -1033,7 +1033,9 @@ void lbs_remove_card(struct lbs_private *priv)
        lbs_deb_enter(LBS_DEB_MAIN);
 
        lbs_remove_mesh(priv);
-       lbs_scan_deinit(priv);
+
+       if (priv->wiphy_registered)
+               lbs_scan_deinit(priv);
 
        /* worker thread destruction blocks on the in-flight command which
         * should have been cleared already in lbs_stop_card().
@@ -1128,6 +1130,11 @@ void lbs_stop_card(struct lbs_private *priv)
                goto out;
        dev = priv->dev;
 
+       /* If the netdev isn't registered, it means that lbs_start_card() was
+        * never called so we have nothing to do here. */
+       if (dev->reg_state != NETREG_REGISTERED)
+               goto out;
+
        netif_stop_queue(dev);
        netif_carrier_off(dev);