Return-path: Received: from smtp1.linux-foundation.org ([140.211.169.13]:53830 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754369AbYG3Tx1 (ORCPT ); Wed, 30 Jul 2008 15:53:27 -0400 Message-Id: <200807301946.m6UJkMcF012994@imap1.linux-foundation.org> (sfid-20080730_215345_371337_AAA29B28) Subject: [patch 3/4] net/ieee80211: adjust error handling To: linville@tuxdriver.com Cc: linux-wireless@vger.kernel.org, akpm@linux-foundation.org, julia@diku.dk, Larry.Finger@lwfinger.net, jbenc@suse.cz, jketreno@linux.intel.com, yi.zhu@intel.com From: akpm@linux-foundation.org Date: Wed, 30 Jul 2008 12:46:22 -0700 Sender: linux-wireless-owner@vger.kernel.org List-ID: From: Julia Lawall 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/) // @@ 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) ) // Signed-off-by: Julia Lawall Cc: James Ketrenos Cc: John W. Linville Cc: Jiri Benc Cc: Zhu Yi Cc: Larry Finger Signed-off-by: Andrew Morton --- net/ieee80211/ieee80211_module.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff -puN net/ieee80211/ieee80211_module.c~net-ieee80211-adjust-error-handling net/ieee80211/ieee80211_module.c --- a/net/ieee80211/ieee80211_module.c~net-ieee80211-adjust-error-handling +++ a/net/ieee80211/ieee80211_module.c @@ -157,7 +157,7 @@ struct net_device *alloc_ieee80211(int s 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 s return dev; - failed: - if (dev) - free_netdev(dev); +failed_free_netdev: + free_netdev(dev); +failed: return NULL; } _