net/ieee80211: adjust error handling
authorJulia Lawall <julia@diku.dk>
Wed, 16 Jul 2008 14:34:54 +0000 (16:34 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 22 Aug 2008 20:29:49 +0000 (16:29 -0400)
Converts a test in error handling code to a sequence of labels.

The semantic match that found the problem is:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@@
expression E,E1,E2;
@@

E = alloc_etherdev(...)
... when != E = E1
if (...) { ... free_netdev(E); ... return ...; }
... when != E = E2
(
  if (...)
   {
   ... when != free_netdev(E);
   return dev; }
|
* if (...)
   {
   ... when != free_netdev(E);
   return ...; }
|
register_netdev(E)
)

// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
net/ieee80211/ieee80211_module.c

index 3bca97f55d47c3b6e7b1591d999bed3800efd64f..949772a5a7dc15bd35152c3ada3df912681acfd7 100644 (file)
@@ -157,7 +157,7 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
        err = ieee80211_networks_allocate(ieee);
        if (err) {
                IEEE80211_ERROR("Unable to allocate beacon storage: %d\n", err);
-               goto failed;
+               goto failed_free_netdev;
        }
        ieee80211_networks_initialize(ieee);
 
@@ -193,9 +193,9 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
 
        return dev;
 
-      failed:
-       if (dev)
-               free_netdev(dev);
+failed_free_netdev:
+       free_netdev(dev);
+failed:
        return NULL;
 }