Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752218Ab1CMF3w (ORCPT ); Sun, 13 Mar 2011 00:29:52 -0500 Received: from mail-qw0-f46.google.com ([209.85.216.46]:50490 "EHLO mail-qw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751195Ab1CMF33 (ORCPT ); Sun, 13 Mar 2011 00:29:29 -0500 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; b=kAg6LQ1ijI/qWDVrIyiEozEir3lPQfdxVURd1ROfilAE63QHT1kRjFFZWWCe+jHAjF SvL7wZyy09K9M6TyUpTHx9RMqRx06Pci8W1sGfCT/s2bRlqSrFBi/vcZmxFLeFFwi9MR TMjI3L3BjquKl7e37xiJCulsdiMcy1IHsdMmk= From: Ilia Mirkin To: Greg Kroah-Hartman Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Brett Rudley , Henry Ptasinski , Dowan Kim , Roland Vossen , Arend van Spriel , linux-wireless@vger.kernel.org Subject: [PATCH 03/24] staging: brcm80211: Remove NULL check before kfree Date: Sun, 13 Mar 2011 00:28:56 -0500 Message-Id: <1299994157-11191-4-git-send-email-imirkin@alum.mit.edu> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1299994157-11191-3-git-send-email-imirkin@alum.mit.edu> References: <20110222145452.GD1331@suse.de> <1299994157-11191-1-git-send-email-imirkin@alum.mit.edu> <1299994157-11191-2-git-send-email-imirkin@alum.mit.edu> <1299994157-11191-3-git-send-email-imirkin@alum.mit.edu> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8920 Lines: 309 This patch was generated by the following semantic patch: // @@ expression E; @@ - if (E != NULL) { kfree(E); } + kfree(E); @@ expression E; @@ - if (E != NULL) { kfree(E); E = NULL; } + kfree(E); + E = NULL; // Signed-off-by: Ilia Mirkin --- drivers/staging/brcm80211/brcmfmac/dhd_cdc.c | 3 +- drivers/staging/brcm80211/brcmfmac/dhd_common.c | 9 ++----- drivers/staging/brcm80211/brcmfmac/dhd_linux.c | 3 +- drivers/staging/brcm80211/brcmfmac/dhd_sdio.c | 24 ++++++------------- .../staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c | 3 +- drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_n.c | 6 +--- drivers/staging/brcm80211/brcmsmac/wl_mac80211.c | 9 ++----- drivers/staging/brcm80211/brcmsmac/wlc_main.c | 6 +--- drivers/staging/brcm80211/util/bcmotp.c | 3 +- drivers/staging/brcm80211/util/bcmsrom.c | 3 +- drivers/staging/brcm80211/util/hnddma.c | 14 ++++------- 11 files changed, 28 insertions(+), 55 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c index 8398fa4..39a4d00 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c @@ -415,8 +415,7 @@ int dhd_prot_attach(dhd_pub_t *dhd) return 0; fail: - if (cdc != NULL) - kfree(cdc); + kfree(cdc); return BCME_NOMEM; } diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c index 64d88c2..aa171f6 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c @@ -996,8 +996,7 @@ dhd_pktfilter_offload_enable(dhd_pub_t *dhd, char *arg, int enable, __func__, arg, rc)); fail: - if (arg_org) - kfree(arg_org); + kfree(arg_org); } void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg) @@ -1132,11 +1131,9 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg) __func__, arg)); fail: - if (arg_org) - kfree(arg_org); + kfree(arg_org); - if (buf) - kfree(buf); + kfree(buf); } void dhd_arp_offload_set(dhd_pub_t *dhd, int arp_mode) diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c index d473f64..02c6d44 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c @@ -1777,8 +1777,7 @@ done: bcmerror = -EFAULT; } - if (buf) - kfree(buf); + kfree(buf); if (bcmerror > 0) bcmerror = 0; diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c index dd2e367..a6da726 100644 --- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c @@ -1930,10 +1930,8 @@ static int dhdsdio_checkdied(dhd_bus_t *bus, u8 *data, uint size) #endif /* DHD_DEBUG */ done: - if (mbuffer) - kfree(mbuffer); - if (str) - kfree(str); + kfree(mbuffer); + kfree(str); return bcmerror; } @@ -1962,8 +1960,7 @@ static int dhdsdio_mem_dump(dhd_bus_t *bus) ret = dhdsdio_membytes(bus, false, start, databuf, read_size); if (ret) { DHD_ERROR(("%s: Error membytes %d\n", __func__, ret)); - if (buf) - kfree(buf); + kfree(buf); return -1; } printk("."); @@ -2081,8 +2078,7 @@ int dhdsdio_downloadvars(dhd_bus_t *bus, void *arg, int len) } /* Free the old ones and replace with passed variables */ - if (bus->vars) - kfree(bus->vars); + kfree(bus->vars); bus->vars = kmalloc(len, GFP_ATOMIC); bus->varsz = bus->vars ? len : 0; @@ -5541,10 +5537,8 @@ static void dhdsdio_release_malloc(dhd_bus_t *bus) bus->rxlen = 0; } - if (bus->databuf) { - kfree(bus->databuf); - bus->databuf = NULL; - } + kfree(bus->databuf); + bus->databuf = NULL; } static void dhdsdio_release_dongle(dhd_bus_t *bus) @@ -5732,8 +5726,7 @@ static int dhdsdio_download_code_file(struct dhd_bus *bus, char *fw_path) } err: - if (memblock) - kfree(memblock); + kfree(memblock); if (image) dhd_os_close_image(image); @@ -5872,8 +5865,7 @@ static int dhdsdio_download_nvram(struct dhd_bus *bus) } err: - if (memblock) - kfree(memblock); + kfree(memblock); if (image) dhd_os_close_image(image); diff --git a/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c index fc810e3..8f75af2 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c @@ -759,8 +759,7 @@ wlc_phy_t *wlc_phy_attach(shared_phy_t *sh, void *regs, int bandtype, char *vars return &pi->pubpi_ro; err: - if (pi) - kfree(pi); + kfree(pi); return NULL; } diff --git a/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_n.c b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_n.c index a385873..7947c60 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_n.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_n.c @@ -22383,8 +22383,7 @@ wlc_phy_gen_load_samples_nphy(phy_info_t *pi, u32 f_kHz, u16 max_val, wlc_phy_loadsampletable_nphy(pi, tone_buf, num_samps); - if (tone_buf != NULL) - kfree(tone_buf); + kfree(tone_buf); return num_samps; } @@ -22431,8 +22430,7 @@ wlc_phy_loadsampletable_nphy(phy_info_t *pi, cs32 *tone_buf, wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_SAMPLEPLAY, num_samps, 0, 32, data_buf); - if (data_buf != NULL) - kfree(data_buf); + kfree(data_buf); if (pi->phyhang_avoid) wlc_phy_stay_in_carriersearch_nphy(pi, false); diff --git a/drivers/staging/brcm80211/brcmsmac/wl_mac80211.c b/drivers/staging/brcm80211/brcmsmac/wl_mac80211.c index 3550551..99fbce7 100644 --- a/drivers/staging/brcm80211/brcmsmac/wl_mac80211.c +++ b/drivers/staging/brcm80211/brcmsmac/wl_mac80211.c @@ -1376,8 +1376,7 @@ static void wl_free(struct wl_info *wl) for (t = wl->timers; t; t = next) { next = t->next; #ifdef BCMDBG - if (t->name) - kfree(t->name); + kfree(t->name); #endif kfree(t); } @@ -1713,8 +1712,7 @@ void wl_free_timer(struct wl_info *wl, struct wl_timer *t) if (wl->timers == t) { wl->timers = wl->timers->next; #ifdef BCMDBG - if (t->name) - kfree(t->name); + kfree(t->name); #endif kfree(t); return; @@ -1726,8 +1724,7 @@ void wl_free_timer(struct wl_info *wl, struct wl_timer *t) if (tmp->next == t) { tmp->next = t->next; #ifdef BCMDBG - if (t->name) - kfree(t->name); + kfree(t->name); #endif kfree(t); return; diff --git a/drivers/staging/brcm80211/brcmsmac/wlc_main.c b/drivers/staging/brcm80211/brcmsmac/wlc_main.c index cb1e142..bc21c54 100644 --- a/drivers/staging/brcm80211/brcmsmac/wlc_main.c +++ b/drivers/staging/brcm80211/brcmsmac/wlc_main.c @@ -2160,10 +2160,8 @@ uint wlc_detach(struct wlc_info *wlc) #ifdef BCMDBG - if (wlc->country_ie_override) { - kfree(wlc->country_ie_override); - wlc->country_ie_override = NULL; - } + kfree(wlc->country_ie_override); + wlc->country_ie_override = NULL; #endif /* BCMDBG */ { diff --git a/drivers/staging/brcm80211/util/bcmotp.c b/drivers/staging/brcm80211/util/bcmotp.c index b080345..ba71c10 100644 --- a/drivers/staging/brcm80211/util/bcmotp.c +++ b/drivers/staging/brcm80211/util/bcmotp.c @@ -830,8 +830,7 @@ static int hndotp_nvread(void *oh, char *data, uint *len) *len = offset; out: - if (rawotp) - kfree(rawotp); + kfree(rawotp); si_setcoreidx(oi->sih, idx); return rc; diff --git a/drivers/staging/brcm80211/util/bcmsrom.c b/drivers/staging/brcm80211/util/bcmsrom.c index 7373603..eca35b9 100644 --- a/drivers/staging/brcm80211/util/bcmsrom.c +++ b/drivers/staging/brcm80211/util/bcmsrom.c @@ -1527,8 +1527,7 @@ static int otp_read_pci(si_t *sih, u16 *buf, uint bufsz) memcpy(buf, otp, bufsz); - if (otp) - kfree(otp); + kfree(otp); /* Check CRC */ if (buf[0] == 0xffff) { diff --git a/drivers/staging/brcm80211/util/hnddma.c b/drivers/staging/brcm80211/util/hnddma.c index 60afd06..89aeca4 100644 --- a/drivers/staging/brcm80211/util/hnddma.c +++ b/drivers/staging/brcm80211/util/hnddma.c @@ -559,21 +559,17 @@ static void _dma_detach(dma_info_t *di) (di->rxdpaorig)); /* free packet pointer vectors */ - if (di->txp) - kfree((void *)di->txp); - if (di->rxp) - kfree((void *)di->rxp); + kfree(di->txp); + kfree(di->rxp); /* free tx packet DMA handles */ - if (di->txp_dmah) - kfree(di->txp_dmah); + kfree(di->txp_dmah); /* free rx packet DMA handles */ - if (di->rxp_dmah) - kfree(di->rxp_dmah); + kfree(di->rxp_dmah); /* free our private info structure */ - kfree((void *)di); + kfree(di); } -- 1.7.3.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/