staging: wlags49_h2: fix error handling in pcmcia probe function
authorAlexey Khoroshilov <khoroshilov@ispras.ru>
Tue, 23 Apr 2013 23:27:39 +0000 (19:27 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 13 May 2013 21:50:06 +0000 (17:50 -0400)
wl_adapter_attach() ignores some important issues
such as register_netdev() failure. The patch fixes it.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wlags49_h2/wl_cs.c
drivers/staging/wlags49_h2/wl_cs.h

index 7c7c77f9c86266e87213c4907b0074dcdf56b2f2..f9e5fd3b02cdcf365a4330f3857a28a4e8139138 100644 (file)
@@ -133,6 +133,7 @@ static int wl_adapter_attach(struct pcmcia_device *link)
 {
        struct net_device   *dev;
        struct wl_private   *lp;
+       int ret;
        /*--------------------------------------------------------------------*/
 
        DBG_FUNC("wl_adapter_attach");
@@ -154,10 +155,12 @@ static int wl_adapter_attach(struct pcmcia_device *link)
        lp = wl_priv(dev);
        lp->link = link;
 
-       wl_adapter_insert(link);
+       ret = wl_adapter_insert(link);
+       if (ret != 0)
+               wl_device_dealloc(dev);
 
        DBG_LEAVE(DbgInfo);
-       return 0;
+       return ret;
 } /* wl_adapter_attach */
 /*============================================================================*/
 
@@ -224,7 +227,7 @@ static int wl_adapter_resume(struct pcmcia_device *link)
        return 0;
 } /* wl_adapter_resume */
 
-void wl_adapter_insert(struct pcmcia_device *link)
+int wl_adapter_insert(struct pcmcia_device *link)
 {
        struct net_device *dev;
        int ret;
@@ -267,13 +270,13 @@ void wl_adapter_insert(struct pcmcia_device *link)
                " %pM\n", dev->name, dev->base_addr, dev->irq, dev->dev_addr);
 
        DBG_LEAVE(DbgInfo);
-       return;
+       return 0;
 
 failed:
        wl_adapter_release(link);
 
        DBG_LEAVE(DbgInfo);
-       return;
+       return ret;
 } /* wl_adapter_insert */
 /*============================================================================*/
 
index a7ab579759ded7f4a41db9b4ea91585b54cc850b..081cc6f28d1f630832c5d79e18f18ac5d6a6d996 100644 (file)
 
 
 /*******************************************************************************
- *  function protoypes
+ *  function prototypes
  ******************************************************************************/
 
-void wl_adapter_insert(struct pcmcia_device *link);
+int wl_adapter_insert(struct pcmcia_device *link);
 
 void wl_adapter_release(struct pcmcia_device *link);