staging: brcm80211: remove NULL pointer checks before calling kfree
authorArend van Spriel <arend@broadcom.com>
Fri, 25 Feb 2011 15:39:23 +0000 (16:39 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 1 Mar 2011 02:19:56 +0000 (18:19 -0800)
kfree function can handle NULL pointer as passed parameter so there
is no need for the calling function to check for this before calling
kfree.

Reviewed-by: Roland Vossen <rvossen@broadcom.com>
Reviewed-by: Brett Rudley <brudley@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/brcm80211/brcmsmac/wlc_alloc.c
drivers/staging/brcm80211/brcmsmac/wlc_ampdu.c
drivers/staging/brcm80211/brcmsmac/wlc_antsel.c
drivers/staging/brcm80211/brcmsmac/wlc_bmac.c
drivers/staging/brcm80211/brcmsmac/wlc_channel.c
drivers/staging/brcm80211/brcmsmac/wlc_phy_shim.c

index 8d6e0ea5d0462e42b95dfbe15732f8c1d4e85f77..fecafc3958e27f2d050ffad14f58f33d066c1999 100644 (file)
@@ -146,17 +146,8 @@ static void wlc_bsscfg_mfree(wlc_bsscfg_t *cfg)
        if (cfg == NULL)
                return;
 
-       if (cfg->maclist) {
-               kfree(cfg->maclist);
-               cfg->maclist = NULL;
-       }
-
-       if (cfg->current_bss != NULL) {
-               wlc_bss_info_t *current_bss = cfg->current_bss;
-               kfree(current_bss);
-               cfg->current_bss = NULL;
-       }
-
+       kfree(cfg->maclist);
+       kfree(cfg->current_bss);
        kfree(cfg);
 }
 
@@ -310,65 +301,19 @@ void wlc_detach_mfree(struct wlc_info *wlc)
        if (wlc == NULL)
                return;
 
-       if (wlc->modulecb) {
-               kfree(wlc->modulecb);
-               wlc->modulecb = NULL;
-       }
-
-       if (wlc->default_bss) {
-               kfree(wlc->default_bss);
-               wlc->default_bss = NULL;
-       }
-       if (wlc->cfg) {
-               wlc_bsscfg_mfree(osh, wlc->cfg);
-               wlc->cfg = NULL;
-       }
-
-       if (wlc->pkt_callback && wlc->pub && wlc->pub->tunables) {
-               kfree(wlc->pkt_callback);
-               wlc->pkt_callback = NULL;
-       }
-
-       if (wlc->wsec_def_keys[0])
-               kfree(wlc->wsec_def_keys[0]);
-       if (wlc->protection) {
-               kfree(wlc->protection);
-               wlc->protection = NULL;
-       }
-
-       if (wlc->stf) {
-               kfree(wlc->stf);
-               wlc->stf = NULL;
-       }
-
-       if (wlc->bandstate[0])
-               kfree(wlc->bandstate[0]);
-
-       if (wlc->corestate) {
-               if (wlc->corestate->macstat_snapshot) {
-                       kfree(wlc->corestate->macstat_snapshot);
-                       wlc->corestate->macstat_snapshot = NULL;
-               }
-               kfree(wlc->corestate);
-               wlc->corestate = NULL;
-       }
-
-       if (wlc->pub) {
-               /* free pub struct */
-               wlc_pub_mfree(osh, wlc->pub);
-               wlc->pub = NULL;
-       }
-
-       if (wlc->hw) {
-               if (wlc->hw->bandstate[0]) {
-                       kfree(wlc->hw->bandstate[0]);
-                       wlc->hw->bandstate[0] = NULL;
-               }
-
-               /* free hw struct */
-               kfree(wlc->hw);
-               wlc->hw = NULL;
-       }
+       wlc_bsscfg_mfree(wlc->cfg);
+       wlc_pub_mfree(wlc->pub);
+       kfree(wlc->modulecb);
+       kfree(wlc->default_bss);
+       kfree(wlc->pkt_callback);
+       kfree(wlc->wsec_def_keys[0]);
+       kfree(wlc->protection);
+       kfree(wlc->stf);
+       kfree(wlc->bandstate[0]);
+       kfree(wlc->corestate->macstat_snapshot);
+       kfree(wlc->corestate);
+       kfree(wlc->hw->bandstate[0]);
+       kfree(wlc->hw);
 
        /* free the wlc */
        kfree(wlc);
index eff174d0827b4f3bc4a91d2bb9e3e5ae947e7e53..19e22c8b2d9cd8df65d45adb9230d9fb9e65ff8e 100644 (file)
@@ -232,9 +232,7 @@ void wlc_ampdu_detach(struct ampdu_info *ampdu)
 
        /* free all ini's which were to be freed on callbacks which were never called */
        for (i = 0; i < AMPDU_INI_FREE; i++) {
-               if (ampdu->ini_free[i]) {
-                       kfree(ampdu->ini_free[i]);
-               }
+               kfree(ampdu->ini_free[i]);
        }
 
        wlc_module_unregister(ampdu->wlc->pub, "ampdu", ampdu);
index 8c59898a418bf0497ff483426daebd24e4ff557d..0a52989313edec538517f5d6c9236f1950f832bf 100644 (file)
@@ -161,9 +161,6 @@ struct antsel_info *wlc_antsel_attach(struct wlc_info *wlc,
 
 void wlc_antsel_detach(struct antsel_info *asi)
 {
-       if (!asi)
-               return;
-
        kfree(asi);
 }
 
index 1a49c6e52e4155b1de38f7c8060336abe20cda61..353f1ea3694cf2d1bc21e041707a3a31231325e8 100644 (file)
@@ -1044,10 +1044,8 @@ int wlc_bmac_detach(struct wlc_info *wlc)
        wlc_phy_shim_detach(wlc_hw->physhim);
 
        /* free vars */
-       if (wlc_hw->vars) {
-               kfree(wlc_hw->vars);
-               wlc_hw->vars = NULL;
-       }
+       kfree(wlc_hw->vars);
+       wlc_hw->vars = NULL;
 
        if (wlc_hw->sih) {
                si_detach(wlc_hw->sih);
index 8e2a3848496c62f957676759f627e27916bf2599..71731a4618c64ffd40cb8df75c8eea172904ff76 100644 (file)
@@ -683,8 +683,7 @@ wlc_cm_info_t *wlc_channel_mgr_attach(struct wlc_info *wlc)
 
 void wlc_channel_mgr_detach(wlc_cm_info_t *wlc_cm)
 {
-       if (wlc_cm)
-               kfree(wlc_cm);
+       kfree(wlc_cm);
 }
 
 u8 wlc_channel_locale_flags_in_band(wlc_cm_info_t *wlc_cm, uint bandunit)
index fa3f73ffff17b305cfd6f275877dece063641f9b..95aafddcc95d5641c1202441eab89dc0af25af9c 100644 (file)
@@ -83,9 +83,6 @@ wlc_phy_shim_info_t *wlc_phy_shim_attach(struct wlc_hw_info *wlc_hw,
 
 void wlc_phy_shim_detach(wlc_phy_shim_info_t *physhim)
 {
-       if (!physhim)
-               return;
-
        kfree(physhim);
 }