All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] staging: remove null checks before kfree
@ 2011-02-22  8:53 Ilia Mirkin
  2011-02-22  8:53 ` [PATCH 2/2] staging: remove null checks before kree(x); x = NULL; Ilia Mirkin
                   ` (2 more replies)
  0 siblings, 3 replies; 35+ messages in thread
From: Ilia Mirkin @ 2011-02-22  8:53 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Greg Kroah-Hartman; +Cc: devel, linux-kernel

This patch was created with the following semantic patch:

// <smpl>
@@
expression E;
@@

- if (E != NULL) kfree(E);
+ kfree(E);
// </smpl>

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---

Hi Greg,

Please let me know if you would rather I split these up by driver instead.
I didn't because I saw that you took staging-wide cleanups before.

 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      |   18 ++++++------------
 .../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_alloc.c     |    6 ++----
 drivers/staging/brcm80211/brcmsmac/wlc_channel.c   |    3 +--
 drivers/staging/brcm80211/util/bcmotp.c            |    3 +--
 drivers/staging/brcm80211/util/bcmsrom.c           |    6 ++----
 drivers/staging/brcm80211/util/hnddma.c            |    6 ++----
 drivers/staging/comedi/drivers/das16.c             |    6 ++----
 drivers/staging/comedi/drivers/ni_at_a2150.c       |    3 +--
 drivers/staging/comedi/drivers/ni_labpc.c          |    3 +--
 drivers/staging/cx25821/cx25821-audio-upstream.c   |    3 +--
 .../staging/cx25821/cx25821-video-upstream-ch2.c   |    3 +--
 drivers/staging/cx25821/cx25821-video-upstream.c   |    3 +--
 drivers/staging/go7007/go7007-usb.c                |    6 ++----
 drivers/staging/hv/channel_mgmt.c                  |    3 +--
 drivers/staging/keucr/ms.c                         |    8 ++++----
 drivers/staging/line6/pcm.c                        |    3 +--
 drivers/staging/pohmelfs/config.c                  |    6 ++----
 drivers/staging/rt2860/common/spectrum.c           |    6 ++----
 drivers/staging/rt2860/rt_linux.c                  |    6 ++----
 .../rtl8187se/ieee80211/ieee80211_softmac.c        |    3 +--
 drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c |    1 -
 drivers/staging/rtl8192e/ieee80211/ieee80211_wx.c  |    1 -
 drivers/staging/rtl8192u/ieee80211/cipher.c        |    3 +--
 drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c  |    1 -
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c      |    3 +--
 drivers/staging/serqt_usb2/serqt_usb2.c            |    3 +--
 drivers/staging/tidspbridge/core/chnl_sm.c         |    3 +--
 drivers/staging/tidspbridge/pmgr/dbll.c            |    3 +--
 drivers/staging/usbip/stub_main.c                  |    6 ++----
 drivers/staging/vme/bridges/vme_ca91cx42.c         |    3 +--
 drivers/staging/vme/bridges/vme_tsi148.c           |    3 +--
 drivers/staging/vt6655/device_main.c               |    3 +--
 drivers/staging/vt6655/hostap.c                    |    3 +--
 drivers/staging/vt6655/wpactl.c                    |    3 +--
 drivers/staging/vt6656/firmware.c                  |    3 +--
 drivers/staging/vt6656/hostap.c                    |    3 +--
 drivers/staging/vt6656/main_usb.c                  |   12 ++++--------
 drivers/staging/vt6656/wpactl.c                    |    3 +--
 drivers/staging/winbond/wb35reg.c                  |    3 +--
 drivers/staging/wlan-ng/prism2fw.c                 |    3 +--
 46 files changed, 68 insertions(+), 135 deletions(-)

diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c
index ed204d5..c0a6cfd 100644
--- a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c
+++ b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c
@@ -417,8 +417,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 b2a6fb2..1857576 100644
--- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c
+++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c
@@ -1003,8 +1003,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)
@@ -1139,11 +1138,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 ffba746..48157b0 100644
--- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c
+++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c
@@ -1787,8 +1787,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 916c555..061cc82 100644
--- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c
+++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c
@@ -1931,10 +1931,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;
 }
@@ -1963,8 +1961,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(".");
@@ -2082,8 +2079,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;
@@ -5763,8 +5759,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);
@@ -5903,8 +5898,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 0760d97..260d464 100644
--- a/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c
+++ b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c
@@ -784,8 +784,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 c6cce8d..49277d8 100644
--- a/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_n.c
+++ b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_n.c
@@ -22386,8 +22386,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;
 }
@@ -22434,8 +22433,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 56f5d3a..9b47679 100644
--- a/drivers/staging/brcm80211/brcmsmac/wl_mac80211.c
+++ b/drivers/staging/brcm80211/brcmsmac/wl_mac80211.c
@@ -1336,8 +1336,7 @@ 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);
 	}
@@ -1664,8 +1663,7 @@ void wl_free_timer(struct wl_info *wl, wl_timer_t *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;
@@ -1677,8 +1675,7 @@ void wl_free_timer(struct wl_info *wl, wl_timer_t *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_alloc.c b/drivers/staging/brcm80211/brcmsmac/wlc_alloc.c
index 2db96c1..b7934ed 100644
--- a/drivers/staging/brcm80211/brcmsmac/wlc_alloc.c
+++ b/drivers/staging/brcm80211/brcmsmac/wlc_alloc.c
@@ -325,8 +325,7 @@ void wlc_detach_mfree(struct wlc_info *wlc, struct osl_info *osh)
 		wlc->pkt_callback = NULL;
 	}
 
-	if (wlc->wsec_def_keys[0])
-		kfree(wlc->wsec_def_keys[0]);
+	kfree(wlc->wsec_def_keys[0]);
 	if (wlc->protection) {
 		kfree(wlc->protection);
 		wlc->protection = NULL;
@@ -337,8 +336,7 @@ void wlc_detach_mfree(struct wlc_info *wlc, struct osl_info *osh)
 		wlc->stf = NULL;
 	}
 
-	if (wlc->bandstate[0])
-		kfree(wlc->bandstate[0]);
+	kfree(wlc->bandstate[0]);
 
 	if (wlc->corestate) {
 		if (wlc->corestate->macstat_snapshot) {
diff --git a/drivers/staging/brcm80211/brcmsmac/wlc_channel.c b/drivers/staging/brcm80211/brcmsmac/wlc_channel.c
index 06b31a0..b69ae21 100644
--- a/drivers/staging/brcm80211/brcmsmac/wlc_channel.c
+++ b/drivers/staging/brcm80211/brcmsmac/wlc_channel.c
@@ -654,8 +654,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)
diff --git a/drivers/staging/brcm80211/util/bcmotp.c b/drivers/staging/brcm80211/util/bcmotp.c
index 6fa04ed..556b180 100644
--- a/drivers/staging/brcm80211/util/bcmotp.c
+++ b/drivers/staging/brcm80211/util/bcmotp.c
@@ -842,8 +842,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 b26877c..3c88018 100644
--- a/drivers/staging/brcm80211/util/bcmsrom.c
+++ b/drivers/staging/brcm80211/util/bcmsrom.c
@@ -1520,8 +1520,7 @@ static int otp_read_pci(struct osl_info *osh, si_t *sih, u16 *buf, uint bufsz)
 
 	memcpy(buf, otp, bufsz);
 
-	if (otp)
-		kfree(otp);
+	kfree(otp);
 
 	/* Check CRC */
 	if (buf[0] == 0xffff) {
@@ -1979,8 +1978,7 @@ static int initvars_srom_pci(si_t *sih, void *curmap, char **vars, uint *count)
 	err = initvars_table(osh, base, vp, vars, count);
 
  errout:
-	if (base)
-		kfree(base);
+	kfree(base);
 
 	kfree(srom);
 	return err;
diff --git a/drivers/staging/brcm80211/util/hnddma.c b/drivers/staging/brcm80211/util/hnddma.c
index 3f1d63e..56fed04 100644
--- a/drivers/staging/brcm80211/util/hnddma.c
+++ b/drivers/staging/brcm80211/util/hnddma.c
@@ -557,12 +557,10 @@ static void _dma_detach(dma_info_t *di)
 		kfree((void *)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);
diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c
index 0af1b46..e7905ba 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -1695,10 +1695,8 @@ static int das16_detach(struct comedi_device *dev)
 		}
 		if (devpriv->dma_chan)
 			free_dma(devpriv->dma_chan);
-		if (devpriv->user_ai_range_table)
-			kfree(devpriv->user_ai_range_table);
-		if (devpriv->user_ao_range_table)
-			kfree(devpriv->user_ao_range_table);
+		kfree(devpriv->user_ai_range_table);
+		kfree(devpriv->user_ao_range_table);
 	}
 
 	if (dev->irq)
diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c
index e46d62b..4d0053e 100644
--- a/drivers/staging/comedi/drivers/ni_at_a2150.c
+++ b/drivers/staging/comedi/drivers/ni_at_a2150.c
@@ -479,8 +479,7 @@ static int a2150_detach(struct comedi_device *dev)
 	if (devpriv) {
 		if (devpriv->dma)
 			free_dma(devpriv->dma);
-		if (devpriv->dma_buffer)
-			kfree(devpriv->dma_buffer);
+		kfree(devpriv->dma_buffer);
 	}
 
 	return 0;
diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c
index 0728c3c..241fe52 100644
--- a/drivers/staging/comedi/drivers/ni_labpc.c
+++ b/drivers/staging/comedi/drivers/ni_labpc.c
@@ -797,8 +797,7 @@ int labpc_common_detach(struct comedi_device *dev)
 		subdev_8255_cleanup(dev, dev->subdevices + 2);
 
 	/* only free stuff if it has been allocated by _attach */
-	if (devpriv->dma_buffer)
-		kfree(devpriv->dma_buffer);
+	kfree(devpriv->dma_buffer);
 	if (devpriv->dma_chan)
 		free_dma(devpriv->dma_chan);
 	if (dev->irq)
diff --git a/drivers/staging/cx25821/cx25821-audio-upstream.c b/drivers/staging/cx25821/cx25821-audio-upstream.c
index 7992a3b..be657df 100644
--- a/drivers/staging/cx25821/cx25821-audio-upstream.c
+++ b/drivers/staging/cx25821/cx25821-audio-upstream.c
@@ -249,8 +249,7 @@ void cx25821_stop_upstream_audio(struct cx25821_dev *dev)
 		dev->_irq_audio_queues = NULL;
 	}
 
-	if (dev->_audiofilename != NULL)
-		kfree(dev->_audiofilename);
+	kfree(dev->_audiofilename);
 }
 
 void cx25821_free_mem_upstream_audio(struct cx25821_dev *dev)
diff --git a/drivers/staging/cx25821/cx25821-video-upstream-ch2.c b/drivers/staging/cx25821/cx25821-video-upstream-ch2.c
index e2efacd..586739d 100644
--- a/drivers/staging/cx25821/cx25821-video-upstream-ch2.c
+++ b/drivers/staging/cx25821/cx25821-video-upstream-ch2.c
@@ -239,8 +239,7 @@ void cx25821_stop_upstream_video_ch2(struct cx25821_dev *dev)
 		dev->_irq_queues_ch2 = NULL;
 	}
 
-	if (dev->_filename_ch2 != NULL)
-		kfree(dev->_filename_ch2);
+	kfree(dev->_filename_ch2);
 
 	tmp = cx_read(VID_CH_MODE_SEL);
 	cx_write(VID_CH_MODE_SEL, tmp & 0xFFFFFE00);
diff --git a/drivers/staging/cx25821/cx25821-video-upstream.c b/drivers/staging/cx25821/cx25821-video-upstream.c
index 31b4e3c..25bfd8a 100644
--- a/drivers/staging/cx25821/cx25821-video-upstream.c
+++ b/drivers/staging/cx25821/cx25821-video-upstream.c
@@ -284,8 +284,7 @@ void cx25821_stop_upstream_video_ch1(struct cx25821_dev *dev)
 		dev->_irq_queues = NULL;
 	}
 
-	if (dev->_filename != NULL)
-		kfree(dev->_filename);
+	kfree(dev->_filename);
 
 	tmp = cx_read(VID_CH_MODE_SEL);
 	cx_write(VID_CH_MODE_SEL, tmp & 0xFFFFFE00);
diff --git a/drivers/staging/go7007/go7007-usb.c b/drivers/staging/go7007/go7007-usb.c
index bea9f4d..3db3b0a 100644
--- a/drivers/staging/go7007/go7007-usb.c
+++ b/drivers/staging/go7007/go7007-usb.c
@@ -1247,15 +1247,13 @@ static void go7007_usb_disconnect(struct usb_interface *intf)
 		vurb = usb->video_urbs[i];
 		if (vurb) {
 			usb_kill_urb(vurb);
-			if (vurb->transfer_buffer)
-				kfree(vurb->transfer_buffer);
+			kfree(vurb->transfer_buffer);
 			usb_free_urb(vurb);
 		}
 		aurb = usb->audio_urbs[i];
 		if (aurb) {
 			usb_kill_urb(aurb);
-			if (aurb->transfer_buffer)
-				kfree(aurb->transfer_buffer);
+			kfree(aurb->transfer_buffer);
 			usb_free_urb(aurb);
 		}
 	}
diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c
index 0781c0e..0fe4e2d 100644
--- a/drivers/staging/hv/channel_mgmt.c
+++ b/drivers/staging/hv/channel_mgmt.c
@@ -829,8 +829,7 @@ int vmbus_request_offers(void)
 
 
 cleanup:
-	if (msginfo)
-		kfree(msginfo);
+	kfree(msginfo);
 
 	return ret;
 }
diff --git a/drivers/staging/keucr/ms.c b/drivers/staging/keucr/ms.c
index 452ea8f..7779d3b 100644
--- a/drivers/staging/keucr/ms.c
+++ b/drivers/staging/keucr/ms.c
@@ -242,8 +242,8 @@ int MS_CardInit(struct us_data *us)
 	result = MS_STATUS_SUCCESS;
 
 exit:
-	if (PageBuffer1)		kfree(PageBuffer1);
-    	if (PageBuffer0)		kfree(PageBuffer0);
+	kfree(PageBuffer1);
+    	kfree(PageBuffer0);
 
 	printk("MS_CardInit end\n");
 	return result;
@@ -278,7 +278,7 @@ int MS_LibCheckDisableBlock(struct us_data *us, WORD PhyBlock)
 	} while(1);
 
 exit:
-	if (PageBuf)	kfree(PageBuf);
+	kfree(PageBuf);
 	return result;
 }
 
@@ -468,7 +468,7 @@ int MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock, BYTE *PageData)
 
 exit:
 	if (result)		MS_LibFreeLogicalMap(us);
-	if (PageBuffer)	kfree(PageBuffer);
+	kfree(PageBuffer);
 
 	result = 0;
 	return result;
diff --git a/drivers/staging/line6/pcm.c b/drivers/staging/line6/pcm.c
index b9c55f9..9d4c8a6 100644
--- a/drivers/staging/line6/pcm.c
+++ b/drivers/staging/line6/pcm.c
@@ -189,8 +189,7 @@ int line6_pcm_stop(struct snd_line6_pcm *line6pcm, int channels)
 		line6pcm->buffer_out = NULL;
 	}
 #if LINE6_BACKUP_MONITOR_SIGNAL
-	if (line6pcm->prev_fbuf != NULL)
-		kfree(line6pcm->prev_fbuf);
+	kfree(line6pcm->prev_fbuf);
 #endif
 
 	return 0;
diff --git a/drivers/staging/pohmelfs/config.c b/drivers/staging/pohmelfs/config.c
index ed91330..a9a3e25 100644
--- a/drivers/staging/pohmelfs/config.c
+++ b/drivers/staging/pohmelfs/config.c
@@ -601,11 +601,9 @@ void pohmelfs_config_exit(void)
 
 		list_del(&g->group_entry);
 
-		if (g->hash_string)
-			kfree(g->hash_string);
+		kfree(g->hash_string);
 
-		if (g->cipher_string)
-			kfree(g->cipher_string);
+		kfree(g->cipher_string);
 
 		kfree(g);
 	}
diff --git a/drivers/staging/rt2860/common/spectrum.c b/drivers/staging/rt2860/common/spectrum.c
index 1dfb802..c0d2f42 100644
--- a/drivers/staging/rt2860/common/spectrum.c
+++ b/drivers/staging/rt2860/common/spectrum.c
@@ -416,8 +416,7 @@ void MeasureReqTabExit(struct rt_rtmp_adapter *pAd)
 {
 	NdisFreeSpinLock(&pAd->CommonCfg.MeasureReqTabLock);
 
-	if (pAd->CommonCfg.pMeasureReqTab)
-		kfree(pAd->CommonCfg.pMeasureReqTab);
+	kfree(pAd->CommonCfg.pMeasureReqTab);
 	pAd->CommonCfg.pMeasureReqTab = NULL;
 
 	return;
@@ -614,8 +613,7 @@ void TpcReqTabExit(struct rt_rtmp_adapter *pAd)
 {
 	NdisFreeSpinLock(&pAd->CommonCfg.TpcReqTabLock);
 
-	if (pAd->CommonCfg.pTpcReqTab)
-		kfree(pAd->CommonCfg.pTpcReqTab);
+	kfree(pAd->CommonCfg.pTpcReqTab);
 	pAd->CommonCfg.pTpcReqTab = NULL;
 
 	return;
diff --git a/drivers/staging/rt2860/rt_linux.c b/drivers/staging/rt2860/rt_linux.c
index b3f836d..e5b0427 100644
--- a/drivers/staging/rt2860/rt_linux.c
+++ b/drivers/staging/rt2860/rt_linux.c
@@ -241,8 +241,7 @@ void RTMPFreeAdapter(struct rt_rtmp_adapter *pAd)
 
 	os_cookie = (struct os_cookie *)pAd->OS_Cookie;
 
-	if (pAd->BeaconBuf)
-		kfree(pAd->BeaconBuf);
+	kfree(pAd->BeaconBuf);
 
 	NdisFreeSpinLock(&pAd->MgmtRingLock);
 
@@ -264,8 +263,7 @@ void RTMPFreeAdapter(struct rt_rtmp_adapter *pAd)
 	release_firmware(pAd->firmware);
 
 	vfree(pAd);		/* pci_free_consistent(os_cookie->pci_dev,sizeof(struct rt_rtmp_adapter),pAd,os_cookie->pAd_pa); */
-	if (os_cookie)
-		kfree(os_cookie);
+	kfree(os_cookie);
 }
 
 BOOLEAN OS_Need_Clone_Packet(void)
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
index 652d879..ef84e06 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
@@ -2604,8 +2604,7 @@ void ieee80211_softmac_free(struct ieee80211_device *ieee)
 	cancel_delayed_work(&ieee->GPIOChangeRFWorkItem);
 
 	destroy_workqueue(ieee->wq);
-	if(NULL != ieee->pDot11dInfo)
-		kfree(ieee->pDot11dInfo);
+	kfree(ieee->pDot11dInfo);
 	up(&ieee->wx_sem);
 }
 
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c
index 07d8dbc..ca414a9 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c
@@ -735,7 +735,6 @@ int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len)
 		ieee->wpa_ie_len = len;
 	}
 	else{
-		if (ieee->wpa_ie)
 		kfree(ieee->wpa_ie);
 		ieee->wpa_ie = NULL;
 		ieee->wpa_ie_len = 0;
diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192e/ieee80211/ieee80211_wx.c
index cac340e..bb0ff26 100644
--- a/drivers/staging/rtl8192e/ieee80211/ieee80211_wx.c
+++ b/drivers/staging/rtl8192e/ieee80211/ieee80211_wx.c
@@ -862,7 +862,6 @@ int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len)
 		ieee->wpa_ie_len = len;
 	}
 	else{
-		if (ieee->wpa_ie)
 		kfree(ieee->wpa_ie);
 		ieee->wpa_ie = NULL;
 		ieee->wpa_ie_len = 0;
diff --git a/drivers/staging/rtl8192u/ieee80211/cipher.c b/drivers/staging/rtl8192u/ieee80211/cipher.c
index 0b9e8a4..69dcc31 100644
--- a/drivers/staging/rtl8192u/ieee80211/cipher.c
+++ b/drivers/staging/rtl8192u/ieee80211/cipher.c
@@ -294,6 +294,5 @@ out:
 
 void crypto_exit_cipher_ops(struct crypto_tfm *tfm)
 {
-	if (tfm->crt_cipher.cit_iv)
-		kfree(tfm->crt_cipher.cit_iv);
+	kfree(tfm->crt_cipher.cit_iv);
 }
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
index d6f55c2..f0ba7f4 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
@@ -855,7 +855,6 @@ int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len)
 		ieee->wpa_ie_len = len;
 	}
 	else{
-		if (ieee->wpa_ie)
 		kfree(ieee->wpa_ie);
 		ieee->wpa_ie = NULL;
 		ieee->wpa_ie_len = 0;
diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
index 221be81..d5eafb5 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -1873,8 +1873,7 @@ static int r871x_mp_ioctl_hdl(struct net_device *dev,
 		goto _r871x_mp_ioctl_hdl_exit;
 	}
 _r871x_mp_ioctl_hdl_exit:
-	if (pparmbuf != NULL)
-		kfree(pparmbuf);
+	kfree(pparmbuf);
 	return ret;
 }
 
diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c
index 27841ef..2be2d88 100644
--- a/drivers/staging/serqt_usb2/serqt_usb2.c
+++ b/drivers/staging/serqt_usb2/serqt_usb2.c
@@ -1098,8 +1098,7 @@ static void qt_close(struct usb_serial_port *port)
 
 	if (qt_port->write_urb) {
 		/* if this urb had a transfer buffer already (old tx) free it */
-		if (qt_port->write_urb->transfer_buffer != NULL)
-			kfree(qt_port->write_urb->transfer_buffer);
+		kfree(qt_port->write_urb->transfer_buffer);
 		usb_free_urb(qt_port->write_urb);
 	}
 
diff --git a/drivers/staging/tidspbridge/core/chnl_sm.c b/drivers/staging/tidspbridge/core/chnl_sm.c
index 3c05d7c..8381130 100644
--- a/drivers/staging/tidspbridge/core/chnl_sm.c
+++ b/drivers/staging/tidspbridge/core/chnl_sm.c
@@ -828,8 +828,7 @@ out_err:
 	free_chirp_list(&pchnl->io_requests);
 	free_chirp_list(&pchnl->free_packets_list);
 
-	if (sync_event)
-		kfree(sync_event);
+	kfree(sync_event);
 
 	if (pchnl->ntfy_obj) {
 		ntfy_delete(pchnl->ntfy_obj);
diff --git a/drivers/staging/tidspbridge/pmgr/dbll.c b/drivers/staging/tidspbridge/pmgr/dbll.c
index 2e20f78e..31da62b 100644
--- a/drivers/staging/tidspbridge/pmgr/dbll.c
+++ b/drivers/staging/tidspbridge/pmgr/dbll.c
@@ -272,8 +272,7 @@ void dbll_delete(struct dbll_tar_obj *target)
 	DBC_REQUIRE(refs > 0);
 	DBC_REQUIRE(zl_target);
 
-	if (zl_target != NULL)
-		kfree(zl_target);
+	kfree(zl_target);
 
 }
 
diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c
index f3a4096..076a7e5 100644
--- a/drivers/staging/usbip/stub_main.c
+++ b/drivers/staging/usbip/stub_main.c
@@ -264,11 +264,9 @@ void stub_device_cleanup_urbs(struct stub_device *sdev)
 
 		kmem_cache_free(stub_priv_cache, priv);
 
-		if (urb->transfer_buffer != NULL)
-			kfree(urb->transfer_buffer);
+		kfree(urb->transfer_buffer);
 
-		if (urb->setup_packet != NULL)
-			kfree(urb->setup_packet);
+		kfree(urb->setup_packet);
 
 		usb_free_urb(urb);
 	}
diff --git a/drivers/staging/vme/bridges/vme_ca91cx42.c b/drivers/staging/vme/bridges/vme_ca91cx42.c
index 42de83e..812b8f2 100644
--- a/drivers/staging/vme/bridges/vme_ca91cx42.c
+++ b/drivers/staging/vme/bridges/vme_ca91cx42.c
@@ -516,8 +516,7 @@ static int ca91cx42_alloc_resource(struct vme_master_resource *image,
 	if (existing_size != 0) {
 		iounmap(image->kern_base);
 		image->kern_base = NULL;
-		if (image->bus_resource.name != NULL)
-			kfree(image->bus_resource.name);
+		kfree(image->bus_resource.name);
 		release_resource(&image->bus_resource);
 		memset(&image->bus_resource, 0, sizeof(struct resource));
 	}
diff --git a/drivers/staging/vme/bridges/vme_tsi148.c b/drivers/staging/vme/bridges/vme_tsi148.c
index 26ea42f..c1eacaa 100644
--- a/drivers/staging/vme/bridges/vme_tsi148.c
+++ b/drivers/staging/vme/bridges/vme_tsi148.c
@@ -821,8 +821,7 @@ static int tsi148_alloc_resource(struct vme_master_resource *image,
 	if (existing_size != 0) {
 		iounmap(image->kern_base);
 		image->kern_base = NULL;
-		if (image->bus_resource.name != NULL)
-			kfree(image->bus_resource.name);
+		kfree(image->bus_resource.name);
 		release_resource(&image->bus_resource);
 		memset(&image->bus_resource, 0, sizeof(struct resource));
 	}
diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index 4fbacf8..8d6a1e1 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -3064,8 +3064,7 @@ else {
 }
 
 error1:
-  if(buffer)
-  	 kfree(buffer);
+  kfree(buffer);
 
   if(filp_close(filp,NULL))
        printk("Config_FileOperation:close file fail\n");
diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
index 5b83f94..7735027 100644
--- a/drivers/staging/vt6655/hostap.c
+++ b/drivers/staging/vt6655/hostap.c
@@ -860,8 +860,7 @@ int vt6655_hostap_ioctl(PSDevice pDevice, struct iw_point *p)
 	}
 
  out:
-	if (param != NULL)
-		kfree(param);
+	kfree(param);
 
 	return ret;
 }
diff --git a/drivers/staging/vt6655/wpactl.c b/drivers/staging/vt6655/wpactl.c
index 4bdb836..fbae16d 100644
--- a/drivers/staging/vt6655/wpactl.c
+++ b/drivers/staging/vt6655/wpactl.c
@@ -987,8 +987,7 @@ int wpa_ioctl(PSDevice pDevice, struct iw_point *p)
 	}
 
 out:
-	if (param != NULL)
-		kfree(param);
+	kfree(param);
 
 	return ret;
 }
diff --git a/drivers/staging/vt6656/firmware.c b/drivers/staging/vt6656/firmware.c
index 1625412..8c8126a 100644
--- a/drivers/staging/vt6656/firmware.c
+++ b/drivers/staging/vt6656/firmware.c
@@ -109,8 +109,7 @@ FIRMWAREbDownload(
 	result = TRUE;
 
 out:
-	if (pBuffer)
-		kfree(pBuffer);
+	kfree(pBuffer);
 
 	spin_lock_irq(&pDevice->lock);
 	return result;
diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
index f70e922..51b5adf 100644
--- a/drivers/staging/vt6656/hostap.c
+++ b/drivers/staging/vt6656/hostap.c
@@ -858,8 +858,7 @@ int vt6656_hostap_ioctl(PSDevice pDevice, struct iw_point *p)
 	}
 
  out:
-	if (param != NULL)
-		kfree(param);
+	kfree(param);
 
 	return ret;
 }
diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
index 56ce9be..61b6121 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -837,8 +837,7 @@ static void device_free_tx_bufs(PSDevice pDevice)
             usb_kill_urb(pTxContext->pUrb);
             usb_free_urb(pTxContext->pUrb);
         }
-        if (pTxContext)
-            kfree(pTxContext);
+        kfree(pTxContext);
     }
     return;
 }
@@ -861,8 +860,7 @@ static void device_free_rx_bufs(PSDevice pDevice)
         if (pRCB->skb)
             dev_kfree_skb(pRCB->skb);
     }
-    if (pDevice->pRCBMem)
-        kfree(pDevice->pRCBMem);
+    kfree(pDevice->pRCBMem);
 
     return;
 }
@@ -878,8 +876,7 @@ static void usb_device_reset(PSDevice pDevice)
 
 static void device_free_int_bufs(PSDevice pDevice)
 {
-    if (pDevice->intBuf.pDataBuf != NULL)
-        kfree(pDevice->intBuf.pDataBuf);
+    kfree(pDevice->intBuf.pDataBuf);
     return;
 }
 
@@ -1480,8 +1477,7 @@ error2:
   */
 
 if(result!=0) {
-    if(buffer)
-  	 kfree(buffer);
+    kfree(buffer);
     buffer=NULL;
 }
   return buffer;
diff --git a/drivers/staging/vt6656/wpactl.c b/drivers/staging/vt6656/wpactl.c
index 7fd300f..8752736 100644
--- a/drivers/staging/vt6656/wpactl.c
+++ b/drivers/staging/vt6656/wpactl.c
@@ -999,8 +999,7 @@ int wpa_ioctl(PSDevice pDevice, struct iw_point *p)
 	}
 
 out:
-	if (param != NULL)
-		kfree(param);
+	kfree(param);
 
 	return ret;
 }
diff --git a/drivers/staging/winbond/wb35reg.c b/drivers/staging/winbond/wb35reg.c
index 42ae610..da595f1 100644
--- a/drivers/staging/winbond/wb35reg.c
+++ b/drivers/staging/winbond/wb35reg.c
@@ -66,8 +66,7 @@ unsigned char Wb35Reg_BurstWrite(struct hw_data *pHwData, u16 RegisterNo, u32 *p
 	} else {
 		if (urb)
 			usb_free_urb(urb);
-		if (reg_queue)
-			kfree(reg_queue);
+		kfree(reg_queue);
 		return false;
 	}
    return false;
diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c
index fd5ddb2..729d03d 100644
--- a/drivers/staging/wlan-ng/prism2fw.c
+++ b/drivers/staging/wlan-ng/prism2fw.c
@@ -443,8 +443,7 @@ void free_chunks(struct imgchunk *fchunk, unsigned int *nfchunks)
 {
 	int i;
 	for (i = 0; i < *nfchunks; i++) {
-		if (fchunk[i].data != NULL)
-			kfree(fchunk[i].data);
+		kfree(fchunk[i].data);
 	}
 	*nfchunks = 0;
 	memset(fchunk, 0, sizeof(*fchunk));
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 2/2] staging: remove null checks before kree(x); x = NULL;
  2011-02-22  8:53 [PATCH 1/2] staging: remove null checks before kfree Ilia Mirkin
@ 2011-02-22  8:53 ` Ilia Mirkin
  2011-02-22 14:54 ` [PATCH 1/2] staging: remove null checks before kfree Greg KH
  2011-02-24 16:08 ` [PATCH 1/2] staging: remove null checks " Steven Rostedt
  2 siblings, 0 replies; 35+ messages in thread
From: Ilia Mirkin @ 2011-02-22  8:53 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Greg Kroah-Hartman; +Cc: devel, linux-kernel

This patch was generated by the following semantic patch:
// <smpl>
@@
expression E;
@@

- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

(And there was one instance in bcm/CmHost.c where I removed the NULL
assignment since that variable was getting immediately reassigned.)

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 drivers/staging/ath6kl/os/linux/ar6k_pal.c         |    6 +--
 drivers/staging/ath6kl/os/linux/hci_bridge.c       |    6 +--
 drivers/staging/bcm/CmHost.c                       |    6 +--
 drivers/staging/brcm80211/brcmfmac/dhd_sdio.c      |    6 +--
 drivers/staging/brcm80211/brcmsmac/wlc_alloc.c     |   41 +++++++-------------
 drivers/staging/brcm80211/brcmsmac/wlc_bmac.c      |    6 +--
 drivers/staging/brcm80211/brcmsmac/wlc_mac80211.c  |   12 ++----
 drivers/staging/comedi/drivers/usbdux.c            |    8 +---
 drivers/staging/cx25821/cx25821-audio-upstream.c   |    6 +--
 .../staging/cx25821/cx25821-video-upstream-ch2.c   |    6 +--
 drivers/staging/cx25821/cx25821-video-upstream.c   |    6 +--
 drivers/staging/keucr/ms.c                         |   14 ++-----
 .../staging/rtl8192e/ieee80211/ieee80211_module.c  |    7 +--
 drivers/staging/rtl8192e/ieee80211/ieee80211_rx.c  |    7 +--
 .../staging/rtl8192e/ieee80211/ieee80211_softmac.c |    7 +--
 .../staging/rtl8192u/ieee80211/ieee80211_module.c  |    7 +--
 drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c  |    7 +--
 .../staging/rtl8192u/ieee80211/ieee80211_softmac.c |    7 +--
 drivers/staging/rtl8192u/r8192U_core.c             |   31 +++++----------
 drivers/staging/speakup/main.c                     |    6 +--
 drivers/staging/wlan-ng/hfa384x_usb.c              |    6 +--
 21 files changed, 65 insertions(+), 143 deletions(-)

diff --git a/drivers/staging/ath6kl/os/linux/ar6k_pal.c b/drivers/staging/ath6kl/os/linux/ar6k_pal.c
index 831b2e3..34d4dc9 100644
--- a/drivers/staging/ath6kl/os/linux/ar6k_pal.c
+++ b/drivers/staging/ath6kl/os/linux/ar6k_pal.c
@@ -260,10 +260,8 @@ static void bt_cleanup_hci_pal(ar6k_hci_pal_info_t *pHciPalInfo)
 		}          
 	}
 
-	if (pHciPalInfo->hdev != NULL) {
-		kfree(pHciPalInfo->hdev);
-		pHciPalInfo->hdev = NULL;
-	}
+	kfree(pHciPalInfo->hdev);
+	pHciPalInfo->hdev = NULL;
 }
 
 /*********************************************************
diff --git a/drivers/staging/ath6kl/os/linux/hci_bridge.c b/drivers/staging/ath6kl/os/linux/hci_bridge.c
index f170382..3c886f3 100644
--- a/drivers/staging/ath6kl/os/linux/hci_bridge.c
+++ b/drivers/staging/ath6kl/os/linux/hci_bridge.c
@@ -929,10 +929,8 @@ static void bt_cleanup_hci(AR6K_HCI_BRIDGE_INFO *pHcidevInfo)
         }          
     }   
     
-    if (pHcidevInfo->pBtStackHCIDev != NULL) {
-        kfree(pHcidevInfo->pBtStackHCIDev);
-        pHcidevInfo->pBtStackHCIDev = NULL;
-    }  
+    kfree(pHcidevInfo->pBtStackHCIDev);
+    pHcidevInfo->pBtStackHCIDev = NULL;  
 }
 
 static int bt_register_hci(AR6K_HCI_BRIDGE_INFO *pHcidevInfo)
diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c
index 5ac4582..51d37b0 100644
--- a/drivers/staging/bcm/CmHost.c
+++ b/drivers/staging/bcm/CmHost.c
@@ -974,11 +974,7 @@ static VOID CopyToAdapter( register PMINI_ADAPTER Adapter,		/**<Pointer to the A
 			!(psfLocalSet->u8RequesttransmissionPolicy &
 				MASK_DISABLE_HEADER_SUPPRESSION);
 
-	if(Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication)
-	{
-		kfree(Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication);
-		Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication = NULL;
-	}
+	kfree(Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication);
 	Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication = pstAddIndication;
 
 	//Re Sort the SF list in PackInfo according to Traffic Priority
diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c
index 061cc82..a2751ff 100644
--- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c
+++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c
@@ -5568,10 +5568,8 @@ static void dhdsdio_release_malloc(dhd_bus_t *bus, struct osl_info *osh)
 		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, struct osl_info *osh)
diff --git a/drivers/staging/brcm80211/brcmsmac/wlc_alloc.c b/drivers/staging/brcm80211/brcmsmac/wlc_alloc.c
index b7934ed..9e1adcd 100644
--- a/drivers/staging/brcm80211/brcmsmac/wlc_alloc.c
+++ b/drivers/staging/brcm80211/brcmsmac/wlc_alloc.c
@@ -140,10 +140,8 @@ void wlc_bsscfg_mfree(struct osl_info *osh, wlc_bsscfg_t *cfg)
 	if (cfg == NULL)
 		return;
 
-	if (cfg->maclist) {
-		kfree(cfg->maclist);
-		cfg->maclist = NULL;
-	}
+	kfree(cfg->maclist);
+	cfg->maclist = NULL;
 
 	if (cfg->current_bss != NULL) {
 		wlc_bss_info_t *current_bss = cfg->current_bss;
@@ -306,15 +304,11 @@ void wlc_detach_mfree(struct wlc_info *wlc, struct osl_info *osh)
 	if (wlc == NULL)
 		return;
 
-	if (wlc->modulecb) {
-		kfree(wlc->modulecb);
-		wlc->modulecb = NULL;
-	}
+	kfree(wlc->modulecb);
+	wlc->modulecb = NULL;
 
-	if (wlc->default_bss) {
-		kfree(wlc->default_bss);
-		wlc->default_bss = NULL;
-	}
+	kfree(wlc->default_bss);
+	wlc->default_bss = NULL;
 	if (wlc->cfg) {
 		wlc_bsscfg_mfree(osh, wlc->cfg);
 		wlc->cfg = NULL;
@@ -326,22 +320,17 @@ void wlc_detach_mfree(struct wlc_info *wlc, struct osl_info *osh)
 	}
 
 	kfree(wlc->wsec_def_keys[0]);
-	if (wlc->protection) {
-		kfree(wlc->protection);
-		wlc->protection = NULL;
-	}
+	kfree(wlc->protection);
+	wlc->protection = NULL;
 
-	if (wlc->stf) {
-		kfree(wlc->stf);
-		wlc->stf = NULL;
-	}
+	kfree(wlc->stf);
+	wlc->stf = NULL;
 
 	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->macstat_snapshot);
+		wlc->corestate->macstat_snapshot = NULL;
 		kfree(wlc->corestate);
 		wlc->corestate = NULL;
 	}
@@ -353,10 +342,8 @@ void wlc_detach_mfree(struct wlc_info *wlc, struct osl_info *osh)
 	}
 
 	if (wlc->hw) {
-		if (wlc->hw->bandstate[0]) {
-			kfree(wlc->hw->bandstate[0]);
-			wlc->hw->bandstate[0] = NULL;
-		}
+		kfree(wlc->hw->bandstate[0]);
+		wlc->hw->bandstate[0] = NULL;
 
 		/* free hw struct */
 		kfree(wlc->hw);
diff --git a/drivers/staging/brcm80211/brcmsmac/wlc_bmac.c b/drivers/staging/brcm80211/brcmsmac/wlc_bmac.c
index ac068cd..7aeddaf 100644
--- a/drivers/staging/brcm80211/brcmsmac/wlc_bmac.c
+++ b/drivers/staging/brcm80211/brcmsmac/wlc_bmac.c
@@ -1045,10 +1045,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);
diff --git a/drivers/staging/brcm80211/brcmsmac/wlc_mac80211.c b/drivers/staging/brcm80211/brcmsmac/wlc_mac80211.c
index 91a2de2..0c3f791 100644
--- a/drivers/staging/brcm80211/brcmsmac/wlc_mac80211.c
+++ b/drivers/staging/brcm80211/brcmsmac/wlc_mac80211.c
@@ -2175,10 +2175,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 */
 
 	{
@@ -8024,10 +8022,8 @@ static void wlc_process_eventq(void *arg)
 	while ((etmp = wlc_eventq_deq(wlc->eventq))) {
 		/* Perform OS specific event processing */
 		wl_event(wlc->wl, etmp->event.ifname, etmp);
-		if (etmp->data) {
-			kfree(etmp->data);
-			etmp->data = NULL;
-		}
+		kfree(etmp->data);
+		etmp->data = NULL;
 		wlc_event_free(wlc->eventq, etmp);
 	}
 }
diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c
index 696ee04..be93c30 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -2265,12 +2265,8 @@ static void tidy_up(struct usbduxsub *usbduxsub_tmp)
 			usbduxsub_unlink_OutURBs(usbduxsub_tmp);
 		}
 		for (i = 0; i < usbduxsub_tmp->numOfOutBuffers; i++) {
-			if (usbduxsub_tmp->urbOut[i]->transfer_buffer) {
-				kfree(usbduxsub_tmp->
-				      urbOut[i]->transfer_buffer);
-				usbduxsub_tmp->urbOut[i]->transfer_buffer =
-				    NULL;
-			}
+			kfree(usbduxsub_tmp->urbOut[i]->transfer_buffer);
+			usbduxsub_tmp->urbOut[i]->transfer_buffer = NULL;
 			if (usbduxsub_tmp->urbOut[i]) {
 				usb_kill_urb(usbduxsub_tmp->urbOut[i]);
 				usb_free_urb(usbduxsub_tmp->urbOut[i]);
diff --git a/drivers/staging/cx25821/cx25821-audio-upstream.c b/drivers/staging/cx25821/cx25821-audio-upstream.c
index be657df..0f9ca77 100644
--- a/drivers/staging/cx25821/cx25821-audio-upstream.c
+++ b/drivers/staging/cx25821/cx25821-audio-upstream.c
@@ -244,10 +244,8 @@ void cx25821_stop_upstream_audio(struct cx25821_dev *dev)
 	dev->_audioframe_count = 0;
 	dev->_audiofile_status = END_OF_FILE;
 
-	if (dev->_irq_audio_queues) {
-		kfree(dev->_irq_audio_queues);
-		dev->_irq_audio_queues = NULL;
-	}
+	kfree(dev->_irq_audio_queues);
+	dev->_irq_audio_queues = NULL;
 
 	kfree(dev->_audiofilename);
 }
diff --git a/drivers/staging/cx25821/cx25821-video-upstream-ch2.c b/drivers/staging/cx25821/cx25821-video-upstream-ch2.c
index 586739d..655357d 100644
--- a/drivers/staging/cx25821/cx25821-video-upstream-ch2.c
+++ b/drivers/staging/cx25821/cx25821-video-upstream-ch2.c
@@ -234,10 +234,8 @@ void cx25821_stop_upstream_video_ch2(struct cx25821_dev *dev)
 	dev->_frame_count_ch2 = 0;
 	dev->_file_status_ch2 = END_OF_FILE;
 
-	if (dev->_irq_queues_ch2) {
-		kfree(dev->_irq_queues_ch2);
-		dev->_irq_queues_ch2 = NULL;
-	}
+	kfree(dev->_irq_queues_ch2);
+	dev->_irq_queues_ch2 = NULL;
 
 	kfree(dev->_filename_ch2);
 
diff --git a/drivers/staging/cx25821/cx25821-video-upstream.c b/drivers/staging/cx25821/cx25821-video-upstream.c
index 25bfd8a..eb0172b 100644
--- a/drivers/staging/cx25821/cx25821-video-upstream.c
+++ b/drivers/staging/cx25821/cx25821-video-upstream.c
@@ -279,10 +279,8 @@ void cx25821_stop_upstream_video_ch1(struct cx25821_dev *dev)
 	dev->_frame_count = 0;
 	dev->_file_status = END_OF_FILE;
 
-	if (dev->_irq_queues) {
-		kfree(dev->_irq_queues);
-		dev->_irq_queues = NULL;
-	}
+	kfree(dev->_irq_queues);
+	dev->_irq_queues = NULL;
 
 	kfree(dev->_filename);
 
diff --git a/drivers/staging/keucr/ms.c b/drivers/staging/keucr/ms.c
index 7779d3b..b8ced85 100644
--- a/drivers/staging/keucr/ms.c
+++ b/drivers/staging/keucr/ms.c
@@ -322,17 +322,11 @@ void MS_LibFreeWriteBuf(struct us_data *us)
 //----- MS_LibFreeLogicalMap() ---------------------------------------
 int MS_LibFreeLogicalMap(struct us_data *us)
 {
-	if (us->MS_Lib.Phy2LogMap)
-	{
-		kfree(us->MS_Lib.Phy2LogMap);
-		us->MS_Lib.Phy2LogMap = NULL;
-	}
+	kfree(us->MS_Lib.Phy2LogMap);
+	us->MS_Lib.Phy2LogMap = NULL;
 
-	if (us->MS_Lib.Log2PhyMap)
-	{
-		kfree(us->MS_Lib.Log2PhyMap);
-		us->MS_Lib.Log2PhyMap = NULL;
-	}
+	kfree(us->MS_Lib.Log2PhyMap);
+	us->MS_Lib.Log2PhyMap = NULL;
 
     return 0;
 }
diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_module.c b/drivers/staging/rtl8192e/ieee80211/ieee80211_module.c
index 67bcd41..663b0b8 100644
--- a/drivers/staging/rtl8192e/ieee80211/ieee80211_module.c
+++ b/drivers/staging/rtl8192e/ieee80211/ieee80211_module.c
@@ -195,11 +195,8 @@ void free_ieee80211(struct net_device *dev)
 {
 	struct ieee80211_device *ieee = netdev_priv(dev);
 	int i;
-	if (ieee->pHTInfo != NULL)
-	{
-		kfree(ieee->pHTInfo);
-		ieee->pHTInfo = NULL;
-	}
+	kfree(ieee->pHTInfo);
+	ieee->pHTInfo = NULL;
 	RemoveAllTS(ieee);
 	ieee80211_softmac_free(ieee);
 	del_timer_sync(&ieee->crypt_deinit_timer);
diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192e/ieee80211/ieee80211_rx.c
index e2eac7c..57acb3f 100644
--- a/drivers/staging/rtl8192e/ieee80211/ieee80211_rx.c
+++ b/drivers/staging/rtl8192e/ieee80211/ieee80211_rx.c
@@ -1411,11 +1411,8 @@ int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
 	return 1;
 
  rx_dropped:
-	if (rxb != NULL)
-	{
-		kfree(rxb);
-		rxb = NULL;
-	}
+	kfree(rxb);
+	rxb = NULL;
 	stats->rx_dropped++;
 
 	/* Returning 0 indicates to caller that we have not handled the SKB--
diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c
index 2640a4f..0de6867 100644
--- a/drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c
@@ -2829,11 +2829,8 @@ void ieee80211_softmac_free(struct ieee80211_device *ieee)
 {
 	down(&ieee->wx_sem);
 #ifdef ENABLE_DOT11D
-	if(NULL != ieee->pDot11dInfo)
-	{
-		kfree(ieee->pDot11dInfo);
-		ieee->pDot11dInfo = NULL;
-	}
+	kfree(ieee->pDot11dInfo);
+	ieee->pDot11dInfo = NULL;
 #endif
 	del_timer_sync(&ieee->associate_timer);
 
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c
index 7455264..fe978f3 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c
@@ -198,11 +198,8 @@ void free_ieee80211(struct net_device *dev)
 	int i;
 	//struct list_head *p, *q;
 //	del_timer_sync(&ieee->SwBwTimer);
-	if (ieee->pHTInfo != NULL)
-	{
-		kfree(ieee->pHTInfo);
-		ieee->pHTInfo = NULL;
-	}
+	kfree(ieee->pHTInfo);
+	ieee->pHTInfo = NULL;
 	RemoveAllTS(ieee);
 	ieee80211_softmac_free(ieee);
 	del_timer_sync(&ieee->crypt_deinit_timer);
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
index 1ea8da3..498b520 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
@@ -1384,11 +1384,8 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
 	return 1;
 
  rx_dropped:
-	if (rxb != NULL)
-	{
-		kfree(rxb);
-		rxb = NULL;
-	}
+	kfree(rxb);
+	rxb = NULL;
 	stats->rx_dropped++;
 
 	/* Returning 0 indicates to caller that we have not handled the SKB--
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
index 20f8c34..4992d63 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
@@ -2755,11 +2755,8 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee)
 void ieee80211_softmac_free(struct ieee80211_device *ieee)
 {
 	down(&ieee->wx_sem);
-	if(NULL != ieee->pDot11dInfo)
-	{
-		kfree(ieee->pDot11dInfo);
-		ieee->pDot11dInfo = NULL;
-	}
+	kfree(ieee->pDot11dInfo);
+	ieee->pDot11dInfo = NULL;
 	del_timer_sync(&ieee->associate_timer);
 
 	cancel_delayed_work(&ieee->associate_retry_wq);
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index ae4f2b9..8d4142a 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -2276,10 +2276,8 @@ void rtl8192_usb_deleteendpoints(struct net_device *dev)
 		kfree(priv->rx_urb);
 		priv->rx_urb = NULL;
 	}
-	if(priv->oldaddr){
-		kfree(priv->oldaddr);
-		priv->oldaddr = NULL;
-	}
+	kfree(priv->oldaddr);
+	priv->oldaddr = NULL;
 	if (priv->pp_rxskb) {
 		kfree(priv->pp_rxskb);
 		priv->pp_rxskb = 0;
@@ -2304,14 +2302,10 @@ void rtl8192_usb_deleteendpoints(struct net_device *dev)
 
 	}
 #else
-	if(priv->rx_urb){
-		kfree(priv->rx_urb);
-		priv->rx_urb = NULL;
-	}
-	if(priv->oldaddr){
-		kfree(priv->oldaddr);
-		priv->oldaddr = NULL;
-	}
+	kfree(priv->rx_urb);
+	priv->rx_urb = NULL;
+	kfree(priv->oldaddr);
+	priv->oldaddr = NULL;
 	if (priv->pp_rxskb) {
 		kfree(priv->pp_rxskb);
 		priv->pp_rxskb = 0;
@@ -5828,10 +5822,8 @@ static int __devinit rtl8192_usb_probe(struct usb_interface *intf,
 
 fail2:
 	rtl8192_down(dev);
-	if (priv->pFirmware) {
-		kfree(priv->pFirmware);
-		priv->pFirmware = NULL;
-	}
+	kfree(priv->pFirmware);
+	priv->pFirmware = NULL;
 	rtl8192_usb_deleteendpoints(dev);
 	destroy_workqueue(priv->priv_wq);
 	mdelay(10);
@@ -5869,11 +5861,8 @@ static void __devexit rtl8192_usb_disconnect(struct usb_interface *intf)
 		rtl8192_proc_remove_one(dev);
 
 			rtl8192_down(dev);
-		if (priv->pFirmware)
-		{
-			kfree(priv->pFirmware);
-			priv->pFirmware = NULL;
-		}
+		kfree(priv->pFirmware);
+		priv->pFirmware = NULL;
 	//	priv->rf_close(dev);
 //		rtl8192_SetRFPowerState(dev, eRfOff);
 		rtl8192_usb_deleteendpoints(dev);
diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
index cd981a1..42fcf7e 100644
--- a/drivers/staging/speakup/main.c
+++ b/drivers/staging/speakup/main.c
@@ -1305,10 +1305,8 @@ void speakup_deallocate(struct vc_data *vc)
 	int vc_num;
 
 	vc_num = vc->vc_num;
-	if (speakup_console[vc_num] != NULL) {
-		kfree(speakup_console[vc_num]);
-		speakup_console[vc_num] = NULL;
-	}
+	kfree(speakup_console[vc_num]);
+	speakup_console[vc_num] = NULL;
 }
 
 static u_char is_cursor;
diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c
index a6efc03..7843dfd 100644
--- a/drivers/staging/wlan-ng/hfa384x_usb.c
+++ b/drivers/staging/wlan-ng/hfa384x_usb.c
@@ -612,10 +612,8 @@ void hfa384x_destroy(hfa384x_t *hw)
 		hfa384x_drvr_stop(hw);
 	hw->state = HFA384x_STATE_PREINIT;
 
-	if (hw->scanresults) {
-		kfree(hw->scanresults);
-		hw->scanresults = NULL;
-	}
+	kfree(hw->scanresults);
+	hw->scanresults = NULL;
 
 	/* Now to clean out the auth queue */
 	while ((skb = skb_dequeue(&hw->authq)))
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* Re: [PATCH 1/2] staging: remove null checks before kfree
  2011-02-22  8:53 [PATCH 1/2] staging: remove null checks before kfree Ilia Mirkin
  2011-02-22  8:53 ` [PATCH 2/2] staging: remove null checks before kree(x); x = NULL; Ilia Mirkin
@ 2011-02-22 14:54 ` Greg KH
  2011-03-13  5:28   ` [PATCH 00/24] Remove NULL check " Ilia Mirkin
  2011-02-24 16:08 ` [PATCH 1/2] staging: remove null checks " Steven Rostedt
  2 siblings, 1 reply; 35+ messages in thread
From: Greg KH @ 2011-02-22 14:54 UTC (permalink / raw)
  To: Ilia Mirkin; +Cc: devel, linux-kernel

On Tue, Feb 22, 2011 at 03:53:40AM -0500, Ilia Mirkin wrote:
> This patch was created with the following semantic patch:
> 
> // <smpl>
> @@
> expression E;
> @@
> 
> - if (E != NULL) kfree(E);
> + kfree(E);
> // </smpl>
> 
> Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
> ---
> 
> Hi Greg,
> 
> Please let me know if you would rather I split these up by driver instead.
> I didn't because I saw that you took staging-wide cleanups before.

Please split these up per-driver, it makes it easier to merge and for
the individual driver authors to review them.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 1/2] staging: remove null checks before kfree
  2011-02-22  8:53 [PATCH 1/2] staging: remove null checks before kfree Ilia Mirkin
  2011-02-22  8:53 ` [PATCH 2/2] staging: remove null checks before kree(x); x = NULL; Ilia Mirkin
  2011-02-22 14:54 ` [PATCH 1/2] staging: remove null checks before kfree Greg KH
@ 2011-02-24 16:08 ` Steven Rostedt
  2011-02-24 17:06   ` Greg KH
  2 siblings, 1 reply; 35+ messages in thread
From: Steven Rostedt @ 2011-02-24 16:08 UTC (permalink / raw)
  To: Ilia Mirkin; +Cc: Greg Kroah-Hartman, devel, linux-kernel

On Tue, Feb 22, 2011 at 03:53:40AM -0500, Ilia Mirkin wrote:
> This patch was created with the following semantic patch:
> 
> // <smpl>
> @@
> expression E;
> @@
> 
> - if (E != NULL) kfree(E);
> + kfree(E);
> // </smpl>

OK, so when will we be removing the unlikely() from the implementations
of kfree()?

	if (unlikely(ZERO_OR_NULL_PTR(block)))
			return;

-- Steve


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 1/2] staging: remove null checks before kfree
  2011-02-24 16:08 ` [PATCH 1/2] staging: remove null checks " Steven Rostedt
@ 2011-02-24 17:06   ` Greg KH
  2011-02-24 17:25     ` Steven Rostedt
  0 siblings, 1 reply; 35+ messages in thread
From: Greg KH @ 2011-02-24 17:06 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: Ilia Mirkin, devel, linux-kernel

On Thu, Feb 24, 2011 at 11:08:29AM -0500, Steven Rostedt wrote:
> On Tue, Feb 22, 2011 at 03:53:40AM -0500, Ilia Mirkin wrote:
> > This patch was created with the following semantic patch:
> > 
> > // <smpl>
> > @@
> > expression E;
> > @@
> > 
> > - if (E != NULL) kfree(E);
> > + kfree(E);
> > // </smpl>
> 
> OK, so when will we be removing the unlikely() from the implementations
> of kfree()?
> 
> 	if (unlikely(ZERO_OR_NULL_PTR(block)))
> 			return;

Have you run the tool that checks for unlikely being true here?  Odds
are, even with all of these changes, the large majority of the time
kfree is called, it has a valid pointer.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 1/2] staging: remove null checks before kfree
  2011-02-24 17:06   ` Greg KH
@ 2011-02-24 17:25     ` Steven Rostedt
  2011-02-24 19:08       ` Ilia Mirkin
  0 siblings, 1 reply; 35+ messages in thread
From: Steven Rostedt @ 2011-02-24 17:25 UTC (permalink / raw)
  To: Greg KH; +Cc: Ilia Mirkin, devel, linux-kernel

On Thu, 2011-02-24 at 09:06 -0800, Greg KH wrote:
> On Thu, Feb 24, 2011 at 11:08:29AM -0500, Steven Rostedt wrote:
> > On Tue, Feb 22, 2011 at 03:53:40AM -0500, Ilia Mirkin wrote:
> > > This patch was created with the following semantic patch:
> > > 
> > > // <smpl>
> > > @@
> > > expression E;
> > > @@
> > > 
> > > - if (E != NULL) kfree(E);
> > > + kfree(E);
> > > // </smpl>
> > 
> > OK, so when will we be removing the unlikely() from the implementations
> > of kfree()?
> > 
> > 	if (unlikely(ZERO_OR_NULL_PTR(block)))
> > 			return;
> 
> Have you run the tool that checks for unlikely being true here?  Odds
> are, even with all of these changes, the large majority of the time
> kfree is called, it has a valid pointer.

Crap, all my saved output files were in the /tmp directory and has since
been purged. I can reboot into the unlikely tracing kernel again, but
that may have to wait. I usually just do that at end of year as a
cleanup.

I can't remember exactly where kfree came in, but IIRC it was on the
list. Maybe not that high though.

-- Steve



^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 1/2] staging: remove null checks before kfree
  2011-02-24 17:25     ` Steven Rostedt
@ 2011-02-24 19:08       ` Ilia Mirkin
  2011-02-24 19:25         ` Steven Rostedt
  0 siblings, 1 reply; 35+ messages in thread
From: Ilia Mirkin @ 2011-02-24 19:08 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: Greg KH, devel, linux-kernel

On Thu, Feb 24, 2011 at 5:25 PM, Steven Rostedt <rostedt@goodmis.org> wrote:
> On Thu, 2011-02-24 at 09:06 -0800, Greg KH wrote:
>> On Thu, Feb 24, 2011 at 11:08:29AM -0500, Steven Rostedt wrote:
>> > On Tue, Feb 22, 2011 at 03:53:40AM -0500, Ilia Mirkin wrote:
>> > > This patch was created with the following semantic patch:
>> > >
>> > > // <smpl>
>> > > @@
>> > > expression E;
>> > > @@
>> > >
>> > > - if (E != NULL) kfree(E);
>> > > + kfree(E);
>> > > // </smpl>
>> >
>> > OK, so when will we be removing the unlikely() from the implementations
>> > of kfree()?
>> >
>> >     if (unlikely(ZERO_OR_NULL_PTR(block)))
>> >                     return;
>>
>> Have you run the tool that checks for unlikely being true here?  Odds
>> are, even with all of these changes, the large majority of the time
>> kfree is called, it has a valid pointer.
>
> Crap, all my saved output files were in the /tmp directory and has since
> been purged. I can reboot into the unlikely tracing kernel again, but
> that may have to wait. I usually just do that at end of year as a
> cleanup.
>
> I can't remember exactly where kfree came in, but IIRC it was on the
> list. Maybe not that high though.

FWIW my reasoning for doing this was that generally the reason you're
freeing something is because you allocated it, so kfree(NULL) happens
rarely -- error paths, conditional features, etc. If you actually
expect the argument to be NULL often, then you would do something like
if (unlikely(x)) kfree(x). This is done a few times in the core
kernel. I think it makes more sense for kfree to keep the unlikely
since in cold paths it won't matter and in hot paths where it is often
NULL, there should be a conditional at the call site. [I'm sure you'll
note the lack of an attached benchmark... this is just what makes
sense to me.]

  -ilia

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 1/2] staging: remove null checks before kfree
  2011-02-24 19:08       ` Ilia Mirkin
@ 2011-02-24 19:25         ` Steven Rostedt
  0 siblings, 0 replies; 35+ messages in thread
From: Steven Rostedt @ 2011-02-24 19:25 UTC (permalink / raw)
  To: Ilia Mirkin; +Cc: Greg KH, devel, linux-kernel

On Thu, 2011-02-24 at 19:08 +0000, Ilia Mirkin wrote:

> FWIW my reasoning for doing this was that generally the reason you're
> freeing something is because you allocated it, so kfree(NULL) happens
> rarely -- error paths, conditional features, etc. If you actually
> expect the argument to be NULL often, then you would do something like
> if (unlikely(x)) kfree(x). This is done a few times in the core
> kernel. I think it makes more sense for kfree to keep the unlikely
> since in cold paths it won't matter and in hot paths where it is often
> NULL, there should be a conditional at the call site. [I'm sure you'll
> note the lack of an attached benchmark... this is just what makes
> sense to me.]

That unlikely has been there for years, and another year wont hurt
anything ;)

I'll run my unlikely clean up again in December, and we'll see what
needs to be touched then.

Thanks,

-- Steve



^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH 00/24] Remove NULL check before kfree
  2011-02-22 14:54 ` [PATCH 1/2] staging: remove null checks before kfree Greg KH
@ 2011-03-13  5:28   ` Ilia Mirkin
  2011-03-13  5:28     ` [PATCH 01/24] staging: ath6kl: " Ilia Mirkin
  0 siblings, 1 reply; 35+ messages in thread
From: Ilia Mirkin @ 2011-03-13  5:28 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, linux-kernel

These patches were generated by the following semantic patch

// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);

@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

with some minor edits against the staging-next branch,
commit 0789b0033112e301f086f99bd15c7d67c051a51e.

Ilia Mirkin (24):
  staging: ath6kl: Remove NULL check before kfree
  staging: bcm: Remove NULL check before kfree
  staging: brcm80211: Remove NULL check before kfree
  staging: comedi: Remove NULL check before kfree
  staging: cx25821: Remove NULL check before kfree
  staging: go7007: Remove NULL check before kfree
  staging: hv: Remove NULL check before kfree
  staging: keucr: Remove NULL check before kfree
  staging: line6: Remove NULL check before kfree
  staging: pohmelfs: Remove NULL check before kfree
  staging: rt2860: Remove NULL check before kfree
  staging: rtl8187se: Remove NULL check before kfree
  staging: rtl8192e: Remove NULL check before kfree
  staging: rtl8192u: Remove NULL check before kfree
  staging: rtl8712: Remove NULL check before kfree
  staging: serqt_usb2: Remove NULL check before kfree
  staging: speakup: Remove NULL check before kfree
  staging: tidspbridge: Remove NULL check before kfree
  staging: usbip: Remove NULL check before kfree
  staging: vme: Remove NULL check before kfree
  staging: vt6655: Remove NULL check before kfree
  staging: vt6656: Remove NULL check before kfree
  staging: winbond: Remove NULL check before kfree
  staging: wlan-ng: Remove NULL check before kfree

 .../staging/ath6kl/hif/sdio/linux_sdio/src/hif.c   |    4 +--
 drivers/staging/ath6kl/os/linux/ar6000_android.c   |    4 +--
 drivers/staging/ath6kl/os/linux/ar6k_pal.c         |    6 +--
 drivers/staging/ath6kl/os/linux/hci_bridge.c       |    6 +--
 drivers/staging/bcm/CmHost.c                       |   11 +-----
 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 +++-----
 drivers/staging/comedi/drivers/8255.c              |    9 +----
 drivers/staging/comedi/drivers/das16.c             |    6 +--
 drivers/staging/comedi/drivers/ni_at_a2150.c       |    3 +-
 drivers/staging/comedi/drivers/ni_labpc.c          |    3 +-
 drivers/staging/comedi/drivers/serial2002.c        |    8 +---
 drivers/staging/comedi/drivers/usbdux.c            |    8 +---
 drivers/staging/cx25821/cx25821-audio-upstream.c   |    9 ++---
 .../staging/cx25821/cx25821-video-upstream-ch2.c   |    9 ++---
 drivers/staging/cx25821/cx25821-video-upstream.c   |    9 ++---
 drivers/staging/go7007/go7007-usb.c                |    6 +--
 drivers/staging/hv/channel_mgmt.c                  |    3 +-
 drivers/staging/hv/connection.c                    |    4 +--
 drivers/staging/hv/hv_mouse.c                      |   12 ++----
 drivers/staging/keucr/ms.c                         |   22 ++++-------
 drivers/staging/line6/pcm.c                        |    3 +-
 drivers/staging/pohmelfs/config.c                  |    6 +--
 drivers/staging/rt2860/common/spectrum.c           |    6 +--
 drivers/staging/rt2860/rt_linux.c                  |    6 +--
 .../rtl8187se/ieee80211/ieee80211_softmac.c        |    3 +-
 drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c |    1 -
 .../staging/rtl8192e/ieee80211/ieee80211_module.c  |    7 +---
 drivers/staging/rtl8192e/ieee80211/ieee80211_rx.c  |    7 +---
 .../staging/rtl8192e/ieee80211/ieee80211_softmac.c |    7 +---
 drivers/staging/rtl8192e/ieee80211/ieee80211_wx.c  |    1 -
 drivers/staging/rtl8192u/ieee80211/cipher.c        |    3 +-
 .../staging/rtl8192u/ieee80211/ieee80211_module.c  |    7 +---
 drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c  |    7 +---
 .../staging/rtl8192u/ieee80211/ieee80211_softmac.c |    7 +---
 drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c  |    1 -
 drivers/staging/rtl8192u/r8192U_core.c             |   39 ++++++--------------
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c      |    3 +-
 drivers/staging/serqt_usb2/serqt_usb2.c            |    3 +-
 drivers/staging/speakup/main.c                     |    6 +--
 drivers/staging/tidspbridge/core/chnl_sm.c         |    3 +-
 drivers/staging/tidspbridge/pmgr/dbll.c            |    3 +-
 drivers/staging/usbip/stub_main.c                  |    6 +--
 drivers/staging/vme/bridges/vme_ca91cx42.c         |    3 +-
 drivers/staging/vme/bridges/vme_tsi148.c           |    3 +-
 drivers/staging/vt6655/device_main.c               |    3 +-
 drivers/staging/vt6655/hostap.c                    |    3 +-
 drivers/staging/vt6655/wpactl.c                    |    3 +-
 drivers/staging/vt6656/firmware.c                  |    3 +-
 drivers/staging/vt6656/hostap.c                    |    3 +-
 drivers/staging/vt6656/main_usb.c                  |   12 ++----
 drivers/staging/vt6656/wpactl.c                    |    3 +-
 drivers/staging/winbond/wb35reg.c                  |    3 +-
 drivers/staging/wlan-ng/hfa384x_usb.c              |    6 +--
 drivers/staging/wlan-ng/prism2fw.c                 |    3 +-
 64 files changed, 127 insertions(+), 281 deletions(-)

-- 
1.7.3.4


^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH 01/24] staging: ath6kl: Remove NULL check before kfree
  2011-03-13  5:28   ` [PATCH 00/24] Remove NULL check " Ilia Mirkin
@ 2011-03-13  5:28     ` Ilia Mirkin
  2011-03-13  5:28       ` [PATCH 02/24] staging: bcm: " Ilia Mirkin
  2011-03-14 17:47       ` [PATCH 01/24] staging: ath6kl: " Luis R. Rodriguez
  0 siblings, 2 replies; 35+ messages in thread
From: Ilia Mirkin @ 2011-03-13  5:28 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, linux-kernel

This patch was generated by the following semantic patch:
// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);

@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 .../staging/ath6kl/hif/sdio/linux_sdio/src/hif.c   |    4 +---
 drivers/staging/ath6kl/os/linux/ar6000_android.c   |    4 +---
 drivers/staging/ath6kl/os/linux/ar6k_pal.c         |    6 ++----
 drivers/staging/ath6kl/os/linux/hci_bridge.c       |    6 ++----
 4 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/ath6kl/hif/sdio/linux_sdio/src/hif.c b/drivers/staging/ath6kl/hif/sdio/linux_sdio/src/hif.c
index b9f8c72..8a1cedb 100644
--- a/drivers/staging/ath6kl/hif/sdio/linux_sdio/src/hif.c
+++ b/drivers/staging/ath6kl/hif/sdio/linux_sdio/src/hif.c
@@ -1214,9 +1214,7 @@ delHifDevice(HIF_DEVICE * device)
 {
     AR_DEBUG_ASSERT(device!= NULL);
     AR_DEBUG_PRINTF(ATH_DEBUG_TRACE, ("AR6000: delHifDevice; 0x%p\n", device));
-    if (device->dma_buffer != NULL) {
-        kfree(device->dma_buffer);
-    }
+    kfree(device->dma_buffer);
     kfree(device);
 }
 
diff --git a/drivers/staging/ath6kl/os/linux/ar6000_android.c b/drivers/staging/ath6kl/os/linux/ar6000_android.c
index f7d1069..002cdc7 100644
--- a/drivers/staging/ath6kl/os/linux/ar6000_android.c
+++ b/drivers/staging/ath6kl/os/linux/ar6000_android.c
@@ -120,9 +120,7 @@ int logger_write(const enum logidx index,
     }
     set_fs(oldfs);
 out_free_message:
-    if (msg) {
-        kfree(msg);
-    }
+    kfree(msg);
     return ret;
 }
 #endif
diff --git a/drivers/staging/ath6kl/os/linux/ar6k_pal.c b/drivers/staging/ath6kl/os/linux/ar6k_pal.c
index fee7cb9..8dd51ee 100644
--- a/drivers/staging/ath6kl/os/linux/ar6k_pal.c
+++ b/drivers/staging/ath6kl/os/linux/ar6k_pal.c
@@ -260,10 +260,8 @@ static void bt_cleanup_hci_pal(ar6k_hci_pal_info_t *pHciPalInfo)
 		}          
 	}
 
-	if (pHciPalInfo->hdev != NULL) {
-		kfree(pHciPalInfo->hdev);
-		pHciPalInfo->hdev = NULL;
-	}
+	kfree(pHciPalInfo->hdev);
+	pHciPalInfo->hdev = NULL;
 }
 
 /*********************************************************
diff --git a/drivers/staging/ath6kl/os/linux/hci_bridge.c b/drivers/staging/ath6kl/os/linux/hci_bridge.c
index a02827b..327aab6 100644
--- a/drivers/staging/ath6kl/os/linux/hci_bridge.c
+++ b/drivers/staging/ath6kl/os/linux/hci_bridge.c
@@ -929,10 +929,8 @@ static void bt_cleanup_hci(struct ar6k_hci_bridge_info *pHcidevInfo)
         }          
     }   
     
-    if (pHcidevInfo->pBtStackHCIDev != NULL) {
-        kfree(pHcidevInfo->pBtStackHCIDev);
-        pHcidevInfo->pBtStackHCIDev = NULL;
-    }  
+    kfree(pHcidevInfo->pBtStackHCIDev);
+    pHcidevInfo->pBtStackHCIDev = NULL;  
 }
 
 static int bt_register_hci(struct ar6k_hci_bridge_info *pHcidevInfo)
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 02/24] staging: bcm: Remove NULL check before kfree
  2011-03-13  5:28     ` [PATCH 01/24] staging: ath6kl: " Ilia Mirkin
@ 2011-03-13  5:28       ` Ilia Mirkin
  2011-03-13  5:28         ` [PATCH 03/24] staging: brcm80211: " Ilia Mirkin
  2011-03-14 17:47       ` [PATCH 01/24] staging: ath6kl: " Luis R. Rodriguez
  1 sibling, 1 reply; 35+ messages in thread
From: Ilia Mirkin @ 2011-03-13  5:28 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, linux-kernel

This patch was generated by the following semantic patch:
// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);

@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 drivers/staging/bcm/CmHost.c |   11 ++---------
 1 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c
index 017b471..9be184f 100644
--- a/drivers/staging/bcm/CmHost.c
+++ b/drivers/staging/bcm/CmHost.c
@@ -974,11 +974,7 @@ static VOID CopyToAdapter( register PMINI_ADAPTER Adapter,		/**<Pointer to the A
 			!(psfLocalSet->u8RequesttransmissionPolicy &
 				MASK_DISABLE_HEADER_SUPPRESSION);
 
-	if(Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication)
-	{
-		kfree(Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication);
-		Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication = NULL;
-	}
+	kfree(Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication);
 	Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication = pstAddIndication;
 
 	//Re Sort the SF list in PackInfo according to Traffic Priority
@@ -1971,10 +1967,7 @@ INT AllocAdapterDsxBuffer(PMINI_ADAPTER Adapter)
 
 INT FreeAdapterDsxBuffer(PMINI_ADAPTER Adapter)
 {
-	if(Adapter->caDsxReqResp)
-	{
-		kfree(Adapter->caDsxReqResp);
-	}
+	kfree(Adapter->caDsxReqResp);
 	return 0;
 
 }
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 03/24] staging: brcm80211: Remove NULL check before kfree
  2011-03-13  5:28       ` [PATCH 02/24] staging: bcm: " Ilia Mirkin
@ 2011-03-13  5:28         ` Ilia Mirkin
  2011-03-13  5:28           ` [PATCH 04/24] staging: comedi: " Ilia Mirkin
  0 siblings, 1 reply; 35+ messages in thread
From: Ilia Mirkin @ 2011-03-13  5:28 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: devel, linux-kernel, Brett Rudley, Henry Ptasinski, Dowan Kim,
	Roland Vossen, Arend van Spriel, linux-wireless

This patch was generated by the following semantic patch:
// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);

@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 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


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 04/24] staging: comedi: Remove NULL check before kfree
  2011-03-13  5:28         ` [PATCH 03/24] staging: brcm80211: " Ilia Mirkin
@ 2011-03-13  5:28           ` Ilia Mirkin
  2011-03-13  5:28             ` [PATCH 05/24] staging: cx25821: " Ilia Mirkin
  0 siblings, 1 reply; 35+ messages in thread
From: Ilia Mirkin @ 2011-03-13  5:28 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, linux-kernel

This patch was generated by the following semantic patch:
// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);

@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 drivers/staging/comedi/drivers/8255.c        |    9 +--------
 drivers/staging/comedi/drivers/das16.c       |    6 ++----
 drivers/staging/comedi/drivers/ni_at_a2150.c |    3 +--
 drivers/staging/comedi/drivers/ni_labpc.c    |    3 +--
 drivers/staging/comedi/drivers/serial2002.c  |    8 ++------
 drivers/staging/comedi/drivers/usbdux.c      |    8 ++------
 6 files changed, 9 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/comedi/drivers/8255.c b/drivers/staging/comedi/drivers/8255.c
index 95049a8..6c26ac8 100644
--- a/drivers/staging/comedi/drivers/8255.c
+++ b/drivers/staging/comedi/drivers/8255.c
@@ -383,14 +383,7 @@ EXPORT_SYMBOL(subdev_8255_init_irq);
 
 void subdev_8255_cleanup(struct comedi_device *dev, struct comedi_subdevice *s)
 {
-	if (s->private) {
-		/* this test does nothing, so comment it out
-		 * if (subdevpriv->have_irq) {
-		 * }
-		 */
-
-		kfree(s->private);
-	}
+	kfree(s->private);
 }
 EXPORT_SYMBOL(subdev_8255_cleanup);
 
diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c
index 0af1b46..e7905ba 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -1695,10 +1695,8 @@ static int das16_detach(struct comedi_device *dev)
 		}
 		if (devpriv->dma_chan)
 			free_dma(devpriv->dma_chan);
-		if (devpriv->user_ai_range_table)
-			kfree(devpriv->user_ai_range_table);
-		if (devpriv->user_ao_range_table)
-			kfree(devpriv->user_ao_range_table);
+		kfree(devpriv->user_ai_range_table);
+		kfree(devpriv->user_ao_range_table);
 	}
 
 	if (dev->irq)
diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c
index e46d62b..4d0053e 100644
--- a/drivers/staging/comedi/drivers/ni_at_a2150.c
+++ b/drivers/staging/comedi/drivers/ni_at_a2150.c
@@ -479,8 +479,7 @@ static int a2150_detach(struct comedi_device *dev)
 	if (devpriv) {
 		if (devpriv->dma)
 			free_dma(devpriv->dma);
-		if (devpriv->dma_buffer)
-			kfree(devpriv->dma_buffer);
+		kfree(devpriv->dma_buffer);
 	}
 
 	return 0;
diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c
index 0728c3c..241fe52 100644
--- a/drivers/staging/comedi/drivers/ni_labpc.c
+++ b/drivers/staging/comedi/drivers/ni_labpc.c
@@ -797,8 +797,7 @@ int labpc_common_detach(struct comedi_device *dev)
 		subdev_8255_cleanup(dev, dev->subdevices + 2);
 
 	/* only free stuff if it has been allocated by _attach */
-	if (devpriv->dma_buffer)
-		kfree(devpriv->dma_buffer);
+	kfree(devpriv->dma_buffer);
 	if (devpriv->dma_chan)
 		free_dma(devpriv->dma_chan);
 	if (dev->irq)
diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c
index c9be9e0..ebfce33 100644
--- a/drivers/staging/comedi/drivers/serial2002.c
+++ b/drivers/staging/comedi/drivers/serial2002.c
@@ -907,12 +907,8 @@ static int serial2002_detach(struct comedi_device *dev)
 	printk("comedi%d: serial2002: remove\n", dev->minor);
 	for (i = 0; i < 5; i++) {
 		s = &dev->subdevices[i];
-		if (s->maxdata_list) {
-			kfree(s->maxdata_list);
-		}
-		if (s->range_table_list) {
-			kfree(s->range_table_list);
-		}
+		kfree(s->maxdata_list);
+		kfree(s->range_table_list);
 	}
 	return 0;
 }
diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c
index 696ee04..be93c30 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -2265,12 +2265,8 @@ static void tidy_up(struct usbduxsub *usbduxsub_tmp)
 			usbduxsub_unlink_OutURBs(usbduxsub_tmp);
 		}
 		for (i = 0; i < usbduxsub_tmp->numOfOutBuffers; i++) {
-			if (usbduxsub_tmp->urbOut[i]->transfer_buffer) {
-				kfree(usbduxsub_tmp->
-				      urbOut[i]->transfer_buffer);
-				usbduxsub_tmp->urbOut[i]->transfer_buffer =
-				    NULL;
-			}
+			kfree(usbduxsub_tmp->urbOut[i]->transfer_buffer);
+			usbduxsub_tmp->urbOut[i]->transfer_buffer = NULL;
 			if (usbduxsub_tmp->urbOut[i]) {
 				usb_kill_urb(usbduxsub_tmp->urbOut[i]);
 				usb_free_urb(usbduxsub_tmp->urbOut[i]);
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 05/24] staging: cx25821: Remove NULL check before kfree
  2011-03-13  5:28           ` [PATCH 04/24] staging: comedi: " Ilia Mirkin
@ 2011-03-13  5:28             ` Ilia Mirkin
  2011-03-13  5:28               ` [PATCH 06/24] staging: go7007: " Ilia Mirkin
  0 siblings, 1 reply; 35+ messages in thread
From: Ilia Mirkin @ 2011-03-13  5:28 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, linux-kernel

This patch was generated by the following semantic patch:
// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);

@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 drivers/staging/cx25821/cx25821-audio-upstream.c   |    9 +++------
 .../staging/cx25821/cx25821-video-upstream-ch2.c   |    9 +++------
 drivers/staging/cx25821/cx25821-video-upstream.c   |    9 +++------
 3 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/cx25821/cx25821-audio-upstream.c b/drivers/staging/cx25821/cx25821-audio-upstream.c
index 7992a3b..0f9ca77 100644
--- a/drivers/staging/cx25821/cx25821-audio-upstream.c
+++ b/drivers/staging/cx25821/cx25821-audio-upstream.c
@@ -244,13 +244,10 @@ void cx25821_stop_upstream_audio(struct cx25821_dev *dev)
 	dev->_audioframe_count = 0;
 	dev->_audiofile_status = END_OF_FILE;
 
-	if (dev->_irq_audio_queues) {
-		kfree(dev->_irq_audio_queues);
-		dev->_irq_audio_queues = NULL;
-	}
+	kfree(dev->_irq_audio_queues);
+	dev->_irq_audio_queues = NULL;
 
-	if (dev->_audiofilename != NULL)
-		kfree(dev->_audiofilename);
+	kfree(dev->_audiofilename);
 }
 
 void cx25821_free_mem_upstream_audio(struct cx25821_dev *dev)
diff --git a/drivers/staging/cx25821/cx25821-video-upstream-ch2.c b/drivers/staging/cx25821/cx25821-video-upstream-ch2.c
index e2efacd..655357d 100644
--- a/drivers/staging/cx25821/cx25821-video-upstream-ch2.c
+++ b/drivers/staging/cx25821/cx25821-video-upstream-ch2.c
@@ -234,13 +234,10 @@ void cx25821_stop_upstream_video_ch2(struct cx25821_dev *dev)
 	dev->_frame_count_ch2 = 0;
 	dev->_file_status_ch2 = END_OF_FILE;
 
-	if (dev->_irq_queues_ch2) {
-		kfree(dev->_irq_queues_ch2);
-		dev->_irq_queues_ch2 = NULL;
-	}
+	kfree(dev->_irq_queues_ch2);
+	dev->_irq_queues_ch2 = NULL;
 
-	if (dev->_filename_ch2 != NULL)
-		kfree(dev->_filename_ch2);
+	kfree(dev->_filename_ch2);
 
 	tmp = cx_read(VID_CH_MODE_SEL);
 	cx_write(VID_CH_MODE_SEL, tmp & 0xFFFFFE00);
diff --git a/drivers/staging/cx25821/cx25821-video-upstream.c b/drivers/staging/cx25821/cx25821-video-upstream.c
index 31b4e3c..eb0172b 100644
--- a/drivers/staging/cx25821/cx25821-video-upstream.c
+++ b/drivers/staging/cx25821/cx25821-video-upstream.c
@@ -279,13 +279,10 @@ void cx25821_stop_upstream_video_ch1(struct cx25821_dev *dev)
 	dev->_frame_count = 0;
 	dev->_file_status = END_OF_FILE;
 
-	if (dev->_irq_queues) {
-		kfree(dev->_irq_queues);
-		dev->_irq_queues = NULL;
-	}
+	kfree(dev->_irq_queues);
+	dev->_irq_queues = NULL;
 
-	if (dev->_filename != NULL)
-		kfree(dev->_filename);
+	kfree(dev->_filename);
 
 	tmp = cx_read(VID_CH_MODE_SEL);
 	cx_write(VID_CH_MODE_SEL, tmp & 0xFFFFFE00);
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 06/24] staging: go7007: Remove NULL check before kfree
  2011-03-13  5:28             ` [PATCH 05/24] staging: cx25821: " Ilia Mirkin
@ 2011-03-13  5:28               ` Ilia Mirkin
  2011-03-13  5:29                 ` [PATCH 07/24] staging: hv: " Ilia Mirkin
  0 siblings, 1 reply; 35+ messages in thread
From: Ilia Mirkin @ 2011-03-13  5:28 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, linux-kernel

This patch was generated by the following semantic patch:
// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);

@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 drivers/staging/go7007/go7007-usb.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/go7007/go7007-usb.c b/drivers/staging/go7007/go7007-usb.c
index bea9f4d..3db3b0a 100644
--- a/drivers/staging/go7007/go7007-usb.c
+++ b/drivers/staging/go7007/go7007-usb.c
@@ -1247,15 +1247,13 @@ static void go7007_usb_disconnect(struct usb_interface *intf)
 		vurb = usb->video_urbs[i];
 		if (vurb) {
 			usb_kill_urb(vurb);
-			if (vurb->transfer_buffer)
-				kfree(vurb->transfer_buffer);
+			kfree(vurb->transfer_buffer);
 			usb_free_urb(vurb);
 		}
 		aurb = usb->audio_urbs[i];
 		if (aurb) {
 			usb_kill_urb(aurb);
-			if (aurb->transfer_buffer)
-				kfree(aurb->transfer_buffer);
+			kfree(aurb->transfer_buffer);
 			usb_free_urb(aurb);
 		}
 	}
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 07/24] staging: hv: Remove NULL check before kfree
  2011-03-13  5:28               ` [PATCH 06/24] staging: go7007: " Ilia Mirkin
@ 2011-03-13  5:29                 ` Ilia Mirkin
  2011-03-13  5:29                   ` [PATCH 08/24] staging: keucr: " Ilia Mirkin
  2011-03-14 19:00                   ` [PATCH 07/24] staging: hv: " Greg KH
  0 siblings, 2 replies; 35+ messages in thread
From: Ilia Mirkin @ 2011-03-13  5:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, linux-kernel

This patch was generated by the following semantic patch:
// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);

@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 drivers/staging/hv/channel_mgmt.c |    3 +--
 drivers/staging/hv/connection.c   |    4 +---
 drivers/staging/hv/hv_mouse.c     |   12 ++++--------
 3 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c
index 0781c0e..0fe4e2d 100644
--- a/drivers/staging/hv/channel_mgmt.c
+++ b/drivers/staging/hv/channel_mgmt.c
@@ -829,8 +829,7 @@ int vmbus_request_offers(void)
 
 
 cleanup:
-	if (msginfo)
-		kfree(msginfo);
+	kfree(msginfo);
 
 	return ret;
 }
diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c
index f7df479..ece66bf 100644
--- a/drivers/staging/hv/connection.c
+++ b/drivers/staging/hv/connection.c
@@ -186,9 +186,7 @@ Cleanup:
 		vmbus_connection.monitor_pages = NULL;
 	}
 
-	if (msginfo) {
-		kfree(msginfo);
-	}
+	kfree(msginfo);
 
 	return ret;
 }
diff --git a/drivers/staging/hv/hv_mouse.c b/drivers/staging/hv/hv_mouse.c
index 8f94f43..6fa4621 100644
--- a/drivers/staging/hv/hv_mouse.c
+++ b/drivers/staging/hv/hv_mouse.c
@@ -402,15 +402,11 @@ static void MousevscOnReceiveDeviceInfo(struct mousevsc_dev *InputDevice, struct
 	return;
 
 Cleanup:
-	if (InputDevice->HidDesc) {
-		kfree(InputDevice->HidDesc);
-		InputDevice->HidDesc = NULL;
-	}
+	kfree(InputDevice->HidDesc);
+	InputDevice->HidDesc = NULL;
 
-	if (InputDevice->ReportDesc) {
-		kfree(InputDevice->ReportDesc);
-		InputDevice->ReportDesc = NULL;
-	}
+	kfree(InputDevice->ReportDesc);
+	InputDevice->ReportDesc = NULL;
 
 	InputDevice->DeviceInfoStatus = -1;
 	InputDevice->device_wait_condition = 1;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 08/24] staging: keucr: Remove NULL check before kfree
  2011-03-13  5:29                 ` [PATCH 07/24] staging: hv: " Ilia Mirkin
@ 2011-03-13  5:29                   ` Ilia Mirkin
  2011-03-13  5:29                     ` [PATCH 09/24] staging: line6: " Ilia Mirkin
  2011-03-14 19:00                   ` [PATCH 07/24] staging: hv: " Greg KH
  1 sibling, 1 reply; 35+ messages in thread
From: Ilia Mirkin @ 2011-03-13  5:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, linux-kernel

This patch was generated by the following semantic patch:
// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);

@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 drivers/staging/keucr/ms.c |   22 ++++++++--------------
 1 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/keucr/ms.c b/drivers/staging/keucr/ms.c
index 48496e4..a713721 100644
--- a/drivers/staging/keucr/ms.c
+++ b/drivers/staging/keucr/ms.c
@@ -244,8 +244,8 @@ int MS_CardInit(struct us_data *us)
 	result = MS_STATUS_SUCCESS;
 
 exit:
-	if (PageBuffer1)		kfree(PageBuffer1);
-    	if (PageBuffer0)		kfree(PageBuffer0);
+	kfree(PageBuffer1);
+    	kfree(PageBuffer0);
 
 	printk("MS_CardInit end\n");
 	return result;
@@ -280,7 +280,7 @@ int MS_LibCheckDisableBlock(struct us_data *us, WORD PhyBlock)
 	} while(1);
 
 exit:
-	if (PageBuf)	kfree(PageBuf);
+	kfree(PageBuf);
 	return result;
 }
 
@@ -324,17 +324,11 @@ void MS_LibFreeWriteBuf(struct us_data *us)
 //----- MS_LibFreeLogicalMap() ---------------------------------------
 int MS_LibFreeLogicalMap(struct us_data *us)
 {
-	if (us->MS_Lib.Phy2LogMap)
-	{
-		kfree(us->MS_Lib.Phy2LogMap);
-		us->MS_Lib.Phy2LogMap = NULL;
-	}
+	kfree(us->MS_Lib.Phy2LogMap);
+	us->MS_Lib.Phy2LogMap = NULL;
 
-	if (us->MS_Lib.Log2PhyMap)
-	{
-		kfree(us->MS_Lib.Log2PhyMap);
-		us->MS_Lib.Log2PhyMap = NULL;
-	}
+	kfree(us->MS_Lib.Log2PhyMap);
+	us->MS_Lib.Log2PhyMap = NULL;
 
     return 0;
 }
@@ -470,7 +464,7 @@ int MS_LibProcessBootBlock(struct us_data *us, WORD PhyBlock, BYTE *PageData)
 
 exit:
 	if (result)		MS_LibFreeLogicalMap(us);
-	if (PageBuffer)	kfree(PageBuffer);
+	kfree(PageBuffer);
 
 	result = 0;
 	return result;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 09/24] staging: line6: Remove NULL check before kfree
  2011-03-13  5:29                   ` [PATCH 08/24] staging: keucr: " Ilia Mirkin
@ 2011-03-13  5:29                     ` Ilia Mirkin
  2011-03-13  5:29                       ` [PATCH 10/24] staging: pohmelfs: " Ilia Mirkin
  0 siblings, 1 reply; 35+ messages in thread
From: Ilia Mirkin @ 2011-03-13  5:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, linux-kernel

This patch was generated by the following semantic patch:
// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);

@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 drivers/staging/line6/pcm.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/line6/pcm.c b/drivers/staging/line6/pcm.c
index b9c55f9..9d4c8a6 100644
--- a/drivers/staging/line6/pcm.c
+++ b/drivers/staging/line6/pcm.c
@@ -189,8 +189,7 @@ int line6_pcm_stop(struct snd_line6_pcm *line6pcm, int channels)
 		line6pcm->buffer_out = NULL;
 	}
 #if LINE6_BACKUP_MONITOR_SIGNAL
-	if (line6pcm->prev_fbuf != NULL)
-		kfree(line6pcm->prev_fbuf);
+	kfree(line6pcm->prev_fbuf);
 #endif
 
 	return 0;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 10/24] staging: pohmelfs: Remove NULL check before kfree
  2011-03-13  5:29                     ` [PATCH 09/24] staging: line6: " Ilia Mirkin
@ 2011-03-13  5:29                       ` Ilia Mirkin
  2011-03-13  5:29                         ` [PATCH 11/24] staging: rt2860: " Ilia Mirkin
  0 siblings, 1 reply; 35+ messages in thread
From: Ilia Mirkin @ 2011-03-13  5:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, linux-kernel

This patch was generated by the following semantic patch:
// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);

@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 drivers/staging/pohmelfs/config.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/pohmelfs/config.c b/drivers/staging/pohmelfs/config.c
index ed91330..a9a3e25 100644
--- a/drivers/staging/pohmelfs/config.c
+++ b/drivers/staging/pohmelfs/config.c
@@ -601,11 +601,9 @@ void pohmelfs_config_exit(void)
 
 		list_del(&g->group_entry);
 
-		if (g->hash_string)
-			kfree(g->hash_string);
+		kfree(g->hash_string);
 
-		if (g->cipher_string)
-			kfree(g->cipher_string);
+		kfree(g->cipher_string);
 
 		kfree(g);
 	}
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 11/24] staging: rt2860: Remove NULL check before kfree
  2011-03-13  5:29                       ` [PATCH 10/24] staging: pohmelfs: " Ilia Mirkin
@ 2011-03-13  5:29                         ` Ilia Mirkin
  2011-03-13  5:29                           ` [PATCH 12/24] staging: rtl8187se: " Ilia Mirkin
  0 siblings, 1 reply; 35+ messages in thread
From: Ilia Mirkin @ 2011-03-13  5:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, linux-kernel

This patch was generated by the following semantic patch:
// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);

@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 drivers/staging/rt2860/common/spectrum.c |    6 ++----
 drivers/staging/rt2860/rt_linux.c        |    6 ++----
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/rt2860/common/spectrum.c b/drivers/staging/rt2860/common/spectrum.c
index 1dfb802..c0d2f42 100644
--- a/drivers/staging/rt2860/common/spectrum.c
+++ b/drivers/staging/rt2860/common/spectrum.c
@@ -416,8 +416,7 @@ void MeasureReqTabExit(struct rt_rtmp_adapter *pAd)
 {
 	NdisFreeSpinLock(&pAd->CommonCfg.MeasureReqTabLock);
 
-	if (pAd->CommonCfg.pMeasureReqTab)
-		kfree(pAd->CommonCfg.pMeasureReqTab);
+	kfree(pAd->CommonCfg.pMeasureReqTab);
 	pAd->CommonCfg.pMeasureReqTab = NULL;
 
 	return;
@@ -614,8 +613,7 @@ void TpcReqTabExit(struct rt_rtmp_adapter *pAd)
 {
 	NdisFreeSpinLock(&pAd->CommonCfg.TpcReqTabLock);
 
-	if (pAd->CommonCfg.pTpcReqTab)
-		kfree(pAd->CommonCfg.pTpcReqTab);
+	kfree(pAd->CommonCfg.pTpcReqTab);
 	pAd->CommonCfg.pTpcReqTab = NULL;
 
 	return;
diff --git a/drivers/staging/rt2860/rt_linux.c b/drivers/staging/rt2860/rt_linux.c
index b3f836d..e5b0427 100644
--- a/drivers/staging/rt2860/rt_linux.c
+++ b/drivers/staging/rt2860/rt_linux.c
@@ -241,8 +241,7 @@ void RTMPFreeAdapter(struct rt_rtmp_adapter *pAd)
 
 	os_cookie = (struct os_cookie *)pAd->OS_Cookie;
 
-	if (pAd->BeaconBuf)
-		kfree(pAd->BeaconBuf);
+	kfree(pAd->BeaconBuf);
 
 	NdisFreeSpinLock(&pAd->MgmtRingLock);
 
@@ -264,8 +263,7 @@ void RTMPFreeAdapter(struct rt_rtmp_adapter *pAd)
 	release_firmware(pAd->firmware);
 
 	vfree(pAd);		/* pci_free_consistent(os_cookie->pci_dev,sizeof(struct rt_rtmp_adapter),pAd,os_cookie->pAd_pa); */
-	if (os_cookie)
-		kfree(os_cookie);
+	kfree(os_cookie);
 }
 
 BOOLEAN OS_Need_Clone_Packet(void)
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 12/24] staging: rtl8187se: Remove NULL check before kfree
  2011-03-13  5:29                         ` [PATCH 11/24] staging: rt2860: " Ilia Mirkin
@ 2011-03-13  5:29                           ` Ilia Mirkin
  2011-03-13  5:29                             ` [PATCH 13/24] staging: rtl8192e: " Ilia Mirkin
  0 siblings, 1 reply; 35+ messages in thread
From: Ilia Mirkin @ 2011-03-13  5:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, linux-kernel

This patch was generated by the following semantic patch:
// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);

@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 .../rtl8187se/ieee80211/ieee80211_softmac.c        |    3 +--
 drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c |    1 -
 2 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
index 74a3b4c..771e019 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
@@ -2605,8 +2605,7 @@ void ieee80211_softmac_free(struct ieee80211_device *ieee)
 	cancel_delayed_work(&ieee->GPIOChangeRFWorkItem);
 
 	destroy_workqueue(ieee->wq);
-	if(NULL != ieee->pDot11dInfo)
-		kfree(ieee->pDot11dInfo);
+	kfree(ieee->pDot11dInfo);
 	up(&ieee->wx_sem);
 }
 
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c
index 07d8dbc..ca414a9 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c
@@ -735,7 +735,6 @@ int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len)
 		ieee->wpa_ie_len = len;
 	}
 	else{
-		if (ieee->wpa_ie)
 		kfree(ieee->wpa_ie);
 		ieee->wpa_ie = NULL;
 		ieee->wpa_ie_len = 0;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 13/24] staging: rtl8192e: Remove NULL check before kfree
  2011-03-13  5:29                           ` [PATCH 12/24] staging: rtl8187se: " Ilia Mirkin
@ 2011-03-13  5:29                             ` Ilia Mirkin
  2011-03-13  5:29                               ` [PATCH 14/24] staging: rtl8192u: " Ilia Mirkin
  0 siblings, 1 reply; 35+ messages in thread
From: Ilia Mirkin @ 2011-03-13  5:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, linux-kernel

This patch was generated by the following semantic patch:
// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);

@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 .../staging/rtl8192e/ieee80211/ieee80211_module.c  |    7 ++-----
 drivers/staging/rtl8192e/ieee80211/ieee80211_rx.c  |    7 ++-----
 .../staging/rtl8192e/ieee80211/ieee80211_softmac.c |    7 ++-----
 drivers/staging/rtl8192e/ieee80211/ieee80211_wx.c  |    1 -
 4 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_module.c b/drivers/staging/rtl8192e/ieee80211/ieee80211_module.c
index 67bcd41..663b0b8 100644
--- a/drivers/staging/rtl8192e/ieee80211/ieee80211_module.c
+++ b/drivers/staging/rtl8192e/ieee80211/ieee80211_module.c
@@ -195,11 +195,8 @@ void free_ieee80211(struct net_device *dev)
 {
 	struct ieee80211_device *ieee = netdev_priv(dev);
 	int i;
-	if (ieee->pHTInfo != NULL)
-	{
-		kfree(ieee->pHTInfo);
-		ieee->pHTInfo = NULL;
-	}
+	kfree(ieee->pHTInfo);
+	ieee->pHTInfo = NULL;
 	RemoveAllTS(ieee);
 	ieee80211_softmac_free(ieee);
 	del_timer_sync(&ieee->crypt_deinit_timer);
diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192e/ieee80211/ieee80211_rx.c
index e2eac7c..57acb3f 100644
--- a/drivers/staging/rtl8192e/ieee80211/ieee80211_rx.c
+++ b/drivers/staging/rtl8192e/ieee80211/ieee80211_rx.c
@@ -1411,11 +1411,8 @@ int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
 	return 1;
 
  rx_dropped:
-	if (rxb != NULL)
-	{
-		kfree(rxb);
-		rxb = NULL;
-	}
+	kfree(rxb);
+	rxb = NULL;
 	stats->rx_dropped++;
 
 	/* Returning 0 indicates to caller that we have not handled the SKB--
diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c
index fc96676..8d73a73 100644
--- a/drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c
@@ -2818,11 +2818,8 @@ void ieee80211_softmac_free(struct ieee80211_device *ieee)
 {
 	down(&ieee->wx_sem);
 #ifdef ENABLE_DOT11D
-	if(NULL != ieee->pDot11dInfo)
-	{
-		kfree(ieee->pDot11dInfo);
-		ieee->pDot11dInfo = NULL;
-	}
+	kfree(ieee->pDot11dInfo);
+	ieee->pDot11dInfo = NULL;
 #endif
 	del_timer_sync(&ieee->associate_timer);
 
diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192e/ieee80211/ieee80211_wx.c
index cac340e..bb0ff26 100644
--- a/drivers/staging/rtl8192e/ieee80211/ieee80211_wx.c
+++ b/drivers/staging/rtl8192e/ieee80211/ieee80211_wx.c
@@ -862,7 +862,6 @@ int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len)
 		ieee->wpa_ie_len = len;
 	}
 	else{
-		if (ieee->wpa_ie)
 		kfree(ieee->wpa_ie);
 		ieee->wpa_ie = NULL;
 		ieee->wpa_ie_len = 0;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 14/24] staging: rtl8192u: Remove NULL check before kfree
  2011-03-13  5:29                             ` [PATCH 13/24] staging: rtl8192e: " Ilia Mirkin
@ 2011-03-13  5:29                               ` Ilia Mirkin
  2011-03-13  5:29                                 ` [PATCH 15/24] staging: rtl8712: " Ilia Mirkin
  0 siblings, 1 reply; 35+ messages in thread
From: Ilia Mirkin @ 2011-03-13  5:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, linux-kernel

This patch was generated by the following semantic patch:
// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);

@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 drivers/staging/rtl8192u/ieee80211/cipher.c        |    3 +-
 .../staging/rtl8192u/ieee80211/ieee80211_module.c  |    7 +---
 drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c  |    7 +---
 .../staging/rtl8192u/ieee80211/ieee80211_softmac.c |    7 +---
 drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c  |    1 -
 drivers/staging/rtl8192u/r8192U_core.c             |   39 ++++++--------------
 6 files changed, 19 insertions(+), 45 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/cipher.c b/drivers/staging/rtl8192u/ieee80211/cipher.c
index 0b9e8a4..69dcc31 100644
--- a/drivers/staging/rtl8192u/ieee80211/cipher.c
+++ b/drivers/staging/rtl8192u/ieee80211/cipher.c
@@ -294,6 +294,5 @@ out:
 
 void crypto_exit_cipher_ops(struct crypto_tfm *tfm)
 {
-	if (tfm->crt_cipher.cit_iv)
-		kfree(tfm->crt_cipher.cit_iv);
+	kfree(tfm->crt_cipher.cit_iv);
 }
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c
index 7455264..fe978f3 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c
@@ -198,11 +198,8 @@ void free_ieee80211(struct net_device *dev)
 	int i;
 	//struct list_head *p, *q;
 //	del_timer_sync(&ieee->SwBwTimer);
-	if (ieee->pHTInfo != NULL)
-	{
-		kfree(ieee->pHTInfo);
-		ieee->pHTInfo = NULL;
-	}
+	kfree(ieee->pHTInfo);
+	ieee->pHTInfo = NULL;
 	RemoveAllTS(ieee);
 	ieee80211_softmac_free(ieee);
 	del_timer_sync(&ieee->crypt_deinit_timer);
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
index 1ea8da3..498b520 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
@@ -1384,11 +1384,8 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
 	return 1;
 
  rx_dropped:
-	if (rxb != NULL)
-	{
-		kfree(rxb);
-		rxb = NULL;
-	}
+	kfree(rxb);
+	rxb = NULL;
 	stats->rx_dropped++;
 
 	/* Returning 0 indicates to caller that we have not handled the SKB--
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
index 20f8c34..4992d63 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
@@ -2755,11 +2755,8 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee)
 void ieee80211_softmac_free(struct ieee80211_device *ieee)
 {
 	down(&ieee->wx_sem);
-	if(NULL != ieee->pDot11dInfo)
-	{
-		kfree(ieee->pDot11dInfo);
-		ieee->pDot11dInfo = NULL;
-	}
+	kfree(ieee->pDot11dInfo);
+	ieee->pDot11dInfo = NULL;
 	del_timer_sync(&ieee->associate_timer);
 
 	cancel_delayed_work(&ieee->associate_retry_wq);
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
index d6f55c2..f0ba7f4 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
@@ -855,7 +855,6 @@ int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len)
 		ieee->wpa_ie_len = len;
 	}
 	else{
-		if (ieee->wpa_ie)
 		kfree(ieee->wpa_ie);
 		ieee->wpa_ie = NULL;
 		ieee->wpa_ie_len = 0;
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index ae4f2b9..da612e6 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -2242,12 +2242,8 @@ short rtl8192_usb_initendpoints(struct net_device *dev)
 
 
 destroy:
-	if (priv->pp_rxskb) {
-		kfree(priv->pp_rxskb);
-	}
-	if (priv->rx_urb) {
-		kfree(priv->rx_urb);
-	}
+	kfree(priv->pp_rxskb);
+	kfree(priv->rx_urb);
 
 	priv->pp_rxskb = NULL;
 	priv->rx_urb = NULL;
@@ -2276,10 +2272,8 @@ void rtl8192_usb_deleteendpoints(struct net_device *dev)
 		kfree(priv->rx_urb);
 		priv->rx_urb = NULL;
 	}
-	if(priv->oldaddr){
-		kfree(priv->oldaddr);
-		priv->oldaddr = NULL;
-	}
+	kfree(priv->oldaddr);
+	priv->oldaddr = NULL;
 	if (priv->pp_rxskb) {
 		kfree(priv->pp_rxskb);
 		priv->pp_rxskb = 0;
@@ -2304,14 +2298,10 @@ void rtl8192_usb_deleteendpoints(struct net_device *dev)
 
 	}
 #else
-	if(priv->rx_urb){
-		kfree(priv->rx_urb);
-		priv->rx_urb = NULL;
-	}
-	if(priv->oldaddr){
-		kfree(priv->oldaddr);
-		priv->oldaddr = NULL;
-	}
+	kfree(priv->rx_urb);
+	priv->rx_urb = NULL;
+	kfree(priv->oldaddr);
+	priv->oldaddr = NULL;
 	if (priv->pp_rxskb) {
 		kfree(priv->pp_rxskb);
 		priv->pp_rxskb = 0;
@@ -5828,10 +5818,8 @@ static int __devinit rtl8192_usb_probe(struct usb_interface *intf,
 
 fail2:
 	rtl8192_down(dev);
-	if (priv->pFirmware) {
-		kfree(priv->pFirmware);
-		priv->pFirmware = NULL;
-	}
+	kfree(priv->pFirmware);
+	priv->pFirmware = NULL;
 	rtl8192_usb_deleteendpoints(dev);
 	destroy_workqueue(priv->priv_wq);
 	mdelay(10);
@@ -5869,11 +5857,8 @@ static void __devexit rtl8192_usb_disconnect(struct usb_interface *intf)
 		rtl8192_proc_remove_one(dev);
 
 			rtl8192_down(dev);
-		if (priv->pFirmware)
-		{
-			kfree(priv->pFirmware);
-			priv->pFirmware = NULL;
-		}
+		kfree(priv->pFirmware);
+		priv->pFirmware = NULL;
 	//	priv->rf_close(dev);
 //		rtl8192_SetRFPowerState(dev, eRfOff);
 		rtl8192_usb_deleteendpoints(dev);
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 15/24] staging: rtl8712: Remove NULL check before kfree
  2011-03-13  5:29                               ` [PATCH 14/24] staging: rtl8192u: " Ilia Mirkin
@ 2011-03-13  5:29                                 ` Ilia Mirkin
  2011-03-13  5:29                                   ` [PATCH 16/24] staging: serqt_usb2: " Ilia Mirkin
  0 siblings, 1 reply; 35+ messages in thread
From: Ilia Mirkin @ 2011-03-13  5:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, linux-kernel

This patch was generated by the following semantic patch:
// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);

@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
index 8ebfdd6..bd315c7 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -1873,8 +1873,7 @@ static int r871x_mp_ioctl_hdl(struct net_device *dev,
 		goto _r871x_mp_ioctl_hdl_exit;
 	}
 _r871x_mp_ioctl_hdl_exit:
-	if (pparmbuf != NULL)
-		kfree(pparmbuf);
+	kfree(pparmbuf);
 	return ret;
 }
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 16/24] staging: serqt_usb2: Remove NULL check before kfree
  2011-03-13  5:29                                 ` [PATCH 15/24] staging: rtl8712: " Ilia Mirkin
@ 2011-03-13  5:29                                   ` Ilia Mirkin
  2011-03-13  5:29                                     ` [PATCH 17/24] staging: speakup: " Ilia Mirkin
  0 siblings, 1 reply; 35+ messages in thread
From: Ilia Mirkin @ 2011-03-13  5:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, linux-kernel

This patch was generated by the following semantic patch:
// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);

@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 drivers/staging/serqt_usb2/serqt_usb2.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c
index 27841ef..2be2d88 100644
--- a/drivers/staging/serqt_usb2/serqt_usb2.c
+++ b/drivers/staging/serqt_usb2/serqt_usb2.c
@@ -1098,8 +1098,7 @@ static void qt_close(struct usb_serial_port *port)
 
 	if (qt_port->write_urb) {
 		/* if this urb had a transfer buffer already (old tx) free it */
-		if (qt_port->write_urb->transfer_buffer != NULL)
-			kfree(qt_port->write_urb->transfer_buffer);
+		kfree(qt_port->write_urb->transfer_buffer);
 		usb_free_urb(qt_port->write_urb);
 	}
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 17/24] staging: speakup: Remove NULL check before kfree
  2011-03-13  5:29                                   ` [PATCH 16/24] staging: serqt_usb2: " Ilia Mirkin
@ 2011-03-13  5:29                                     ` Ilia Mirkin
  2011-03-13  5:29                                       ` [PATCH 18/24] staging: tidspbridge: " Ilia Mirkin
  0 siblings, 1 reply; 35+ messages in thread
From: Ilia Mirkin @ 2011-03-13  5:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, linux-kernel

This patch was generated by the following semantic patch:
// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);

@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 drivers/staging/speakup/main.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
index cd981a1..42fcf7e 100644
--- a/drivers/staging/speakup/main.c
+++ b/drivers/staging/speakup/main.c
@@ -1305,10 +1305,8 @@ void speakup_deallocate(struct vc_data *vc)
 	int vc_num;
 
 	vc_num = vc->vc_num;
-	if (speakup_console[vc_num] != NULL) {
-		kfree(speakup_console[vc_num]);
-		speakup_console[vc_num] = NULL;
-	}
+	kfree(speakup_console[vc_num]);
+	speakup_console[vc_num] = NULL;
 }
 
 static u_char is_cursor;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 18/24] staging: tidspbridge: Remove NULL check before kfree
  2011-03-13  5:29                                     ` [PATCH 17/24] staging: speakup: " Ilia Mirkin
@ 2011-03-13  5:29                                       ` Ilia Mirkin
  2011-03-13  5:29                                         ` [PATCH 19/24] staging: usbip: " Ilia Mirkin
  0 siblings, 1 reply; 35+ messages in thread
From: Ilia Mirkin @ 2011-03-13  5:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, linux-kernel

This patch was generated by the following semantic patch:
// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);

@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 drivers/staging/tidspbridge/core/chnl_sm.c |    3 +--
 drivers/staging/tidspbridge/pmgr/dbll.c    |    3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/tidspbridge/core/chnl_sm.c b/drivers/staging/tidspbridge/core/chnl_sm.c
index 3c05d7c..8381130 100644
--- a/drivers/staging/tidspbridge/core/chnl_sm.c
+++ b/drivers/staging/tidspbridge/core/chnl_sm.c
@@ -828,8 +828,7 @@ out_err:
 	free_chirp_list(&pchnl->io_requests);
 	free_chirp_list(&pchnl->free_packets_list);
 
-	if (sync_event)
-		kfree(sync_event);
+	kfree(sync_event);
 
 	if (pchnl->ntfy_obj) {
 		ntfy_delete(pchnl->ntfy_obj);
diff --git a/drivers/staging/tidspbridge/pmgr/dbll.c b/drivers/staging/tidspbridge/pmgr/dbll.c
index 2e20f78e..31da62b 100644
--- a/drivers/staging/tidspbridge/pmgr/dbll.c
+++ b/drivers/staging/tidspbridge/pmgr/dbll.c
@@ -272,8 +272,7 @@ void dbll_delete(struct dbll_tar_obj *target)
 	DBC_REQUIRE(refs > 0);
 	DBC_REQUIRE(zl_target);
 
-	if (zl_target != NULL)
-		kfree(zl_target);
+	kfree(zl_target);
 
 }
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 19/24] staging: usbip: Remove NULL check before kfree
  2011-03-13  5:29                                       ` [PATCH 18/24] staging: tidspbridge: " Ilia Mirkin
@ 2011-03-13  5:29                                         ` Ilia Mirkin
  2011-03-13  5:29                                           ` [PATCH 20/24] staging: vme: " Ilia Mirkin
  0 siblings, 1 reply; 35+ messages in thread
From: Ilia Mirkin @ 2011-03-13  5:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, linux-kernel

This patch was generated by the following semantic patch:
// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);

@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 drivers/staging/usbip/stub_main.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c
index f3a4096..076a7e5 100644
--- a/drivers/staging/usbip/stub_main.c
+++ b/drivers/staging/usbip/stub_main.c
@@ -264,11 +264,9 @@ void stub_device_cleanup_urbs(struct stub_device *sdev)
 
 		kmem_cache_free(stub_priv_cache, priv);
 
-		if (urb->transfer_buffer != NULL)
-			kfree(urb->transfer_buffer);
+		kfree(urb->transfer_buffer);
 
-		if (urb->setup_packet != NULL)
-			kfree(urb->setup_packet);
+		kfree(urb->setup_packet);
 
 		usb_free_urb(urb);
 	}
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 20/24] staging: vme: Remove NULL check before kfree
  2011-03-13  5:29                                         ` [PATCH 19/24] staging: usbip: " Ilia Mirkin
@ 2011-03-13  5:29                                           ` Ilia Mirkin
  2011-03-13  5:29                                             ` [PATCH 21/24] staging: vt6655: " Ilia Mirkin
  0 siblings, 1 reply; 35+ messages in thread
From: Ilia Mirkin @ 2011-03-13  5:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, linux-kernel

This patch was generated by the following semantic patch:
// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);

@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 drivers/staging/vme/bridges/vme_ca91cx42.c |    3 +--
 drivers/staging/vme/bridges/vme_tsi148.c   |    3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vme/bridges/vme_ca91cx42.c b/drivers/staging/vme/bridges/vme_ca91cx42.c
index 5d734d9..d4a48c4 100644
--- a/drivers/staging/vme/bridges/vme_ca91cx42.c
+++ b/drivers/staging/vme/bridges/vme_ca91cx42.c
@@ -516,8 +516,7 @@ static int ca91cx42_alloc_resource(struct vme_master_resource *image,
 	if (existing_size != 0) {
 		iounmap(image->kern_base);
 		image->kern_base = NULL;
-		if (image->bus_resource.name != NULL)
-			kfree(image->bus_resource.name);
+		kfree(image->bus_resource.name);
 		release_resource(&image->bus_resource);
 		memset(&image->bus_resource, 0, sizeof(struct resource));
 	}
diff --git a/drivers/staging/vme/bridges/vme_tsi148.c b/drivers/staging/vme/bridges/vme_tsi148.c
index 2df19ea..b00a53e 100644
--- a/drivers/staging/vme/bridges/vme_tsi148.c
+++ b/drivers/staging/vme/bridges/vme_tsi148.c
@@ -821,8 +821,7 @@ static int tsi148_alloc_resource(struct vme_master_resource *image,
 	if (existing_size != 0) {
 		iounmap(image->kern_base);
 		image->kern_base = NULL;
-		if (image->bus_resource.name != NULL)
-			kfree(image->bus_resource.name);
+		kfree(image->bus_resource.name);
 		release_resource(&image->bus_resource);
 		memset(&image->bus_resource, 0, sizeof(struct resource));
 	}
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 21/24] staging: vt6655: Remove NULL check before kfree
  2011-03-13  5:29                                           ` [PATCH 20/24] staging: vme: " Ilia Mirkin
@ 2011-03-13  5:29                                             ` Ilia Mirkin
  2011-03-13  5:29                                               ` [PATCH 22/24] staging: vt6656: " Ilia Mirkin
  0 siblings, 1 reply; 35+ messages in thread
From: Ilia Mirkin @ 2011-03-13  5:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, linux-kernel

This patch was generated by the following semantic patch:
// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);

@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 drivers/staging/vt6655/device_main.c |    3 +--
 drivers/staging/vt6655/hostap.c      |    3 +--
 drivers/staging/vt6655/wpactl.c      |    3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index 638e391..efaf19b 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -3064,8 +3064,7 @@ else {
 }
 
 error1:
-  if(buffer)
-  	 kfree(buffer);
+  kfree(buffer);
 
   if(filp_close(filp,NULL))
        printk("Config_FileOperation:close file fail\n");
diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
index 5b83f94..7735027 100644
--- a/drivers/staging/vt6655/hostap.c
+++ b/drivers/staging/vt6655/hostap.c
@@ -860,8 +860,7 @@ int vt6655_hostap_ioctl(PSDevice pDevice, struct iw_point *p)
 	}
 
  out:
-	if (param != NULL)
-		kfree(param);
+	kfree(param);
 
 	return ret;
 }
diff --git a/drivers/staging/vt6655/wpactl.c b/drivers/staging/vt6655/wpactl.c
index 4bdb836..fbae16d 100644
--- a/drivers/staging/vt6655/wpactl.c
+++ b/drivers/staging/vt6655/wpactl.c
@@ -987,8 +987,7 @@ int wpa_ioctl(PSDevice pDevice, struct iw_point *p)
 	}
 
 out:
-	if (param != NULL)
-		kfree(param);
+	kfree(param);
 
 	return ret;
 }
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 22/24] staging: vt6656: Remove NULL check before kfree
  2011-03-13  5:29                                             ` [PATCH 21/24] staging: vt6655: " Ilia Mirkin
@ 2011-03-13  5:29                                               ` Ilia Mirkin
  2011-03-13  5:29                                                 ` [PATCH 23/24] staging: winbond: " Ilia Mirkin
  0 siblings, 1 reply; 35+ messages in thread
From: Ilia Mirkin @ 2011-03-13  5:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, linux-kernel

This patch was generated by the following semantic patch:
// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);

@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 drivers/staging/vt6656/firmware.c |    3 +--
 drivers/staging/vt6656/hostap.c   |    3 +--
 drivers/staging/vt6656/main_usb.c |   12 ++++--------
 drivers/staging/vt6656/wpactl.c   |    3 +--
 4 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/vt6656/firmware.c b/drivers/staging/vt6656/firmware.c
index 1625412..8c8126a 100644
--- a/drivers/staging/vt6656/firmware.c
+++ b/drivers/staging/vt6656/firmware.c
@@ -109,8 +109,7 @@ FIRMWAREbDownload(
 	result = TRUE;
 
 out:
-	if (pBuffer)
-		kfree(pBuffer);
+	kfree(pBuffer);
 
 	spin_lock_irq(&pDevice->lock);
 	return result;
diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
index f70e922..51b5adf 100644
--- a/drivers/staging/vt6656/hostap.c
+++ b/drivers/staging/vt6656/hostap.c
@@ -858,8 +858,7 @@ int vt6656_hostap_ioctl(PSDevice pDevice, struct iw_point *p)
 	}
 
  out:
-	if (param != NULL)
-		kfree(param);
+	kfree(param);
 
 	return ret;
 }
diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
index 37d6396..af14ab0 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -837,8 +837,7 @@ static void device_free_tx_bufs(PSDevice pDevice)
             usb_kill_urb(pTxContext->pUrb);
             usb_free_urb(pTxContext->pUrb);
         }
-        if (pTxContext)
-            kfree(pTxContext);
+        kfree(pTxContext);
     }
     return;
 }
@@ -861,8 +860,7 @@ static void device_free_rx_bufs(PSDevice pDevice)
         if (pRCB->skb)
             dev_kfree_skb(pRCB->skb);
     }
-    if (pDevice->pRCBMem)
-        kfree(pDevice->pRCBMem);
+    kfree(pDevice->pRCBMem);
 
     return;
 }
@@ -878,8 +876,7 @@ static void usb_device_reset(PSDevice pDevice)
 
 static void device_free_int_bufs(PSDevice pDevice)
 {
-    if (pDevice->intBuf.pDataBuf != NULL)
-        kfree(pDevice->intBuf.pDataBuf);
+    kfree(pDevice->intBuf.pDataBuf);
     return;
 }
 
@@ -1480,8 +1477,7 @@ error2:
   */
 
 if(result!=0) {
-    if(buffer)
-  	 kfree(buffer);
+    kfree(buffer);
     buffer=NULL;
 }
   return buffer;
diff --git a/drivers/staging/vt6656/wpactl.c b/drivers/staging/vt6656/wpactl.c
index 7fd300f..8752736 100644
--- a/drivers/staging/vt6656/wpactl.c
+++ b/drivers/staging/vt6656/wpactl.c
@@ -999,8 +999,7 @@ int wpa_ioctl(PSDevice pDevice, struct iw_point *p)
 	}
 
 out:
-	if (param != NULL)
-		kfree(param);
+	kfree(param);
 
 	return ret;
 }
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 23/24] staging: winbond: Remove NULL check before kfree
  2011-03-13  5:29                                               ` [PATCH 22/24] staging: vt6656: " Ilia Mirkin
@ 2011-03-13  5:29                                                 ` Ilia Mirkin
  2011-03-13  5:29                                                   ` [PATCH 24/24] staging: wlan-ng: " Ilia Mirkin
  0 siblings, 1 reply; 35+ messages in thread
From: Ilia Mirkin @ 2011-03-13  5:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, linux-kernel

This patch was generated by the following semantic patch:
// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);

@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 drivers/staging/winbond/wb35reg.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/winbond/wb35reg.c b/drivers/staging/winbond/wb35reg.c
index 42ae610..da595f1 100644
--- a/drivers/staging/winbond/wb35reg.c
+++ b/drivers/staging/winbond/wb35reg.c
@@ -66,8 +66,7 @@ unsigned char Wb35Reg_BurstWrite(struct hw_data *pHwData, u16 RegisterNo, u32 *p
 	} else {
 		if (urb)
 			usb_free_urb(urb);
-		if (reg_queue)
-			kfree(reg_queue);
+		kfree(reg_queue);
 		return false;
 	}
    return false;
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 24/24] staging: wlan-ng: Remove NULL check before kfree
  2011-03-13  5:29                                                 ` [PATCH 23/24] staging: winbond: " Ilia Mirkin
@ 2011-03-13  5:29                                                   ` Ilia Mirkin
  0 siblings, 0 replies; 35+ messages in thread
From: Ilia Mirkin @ 2011-03-13  5:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: devel, linux-kernel

This patch was generated by the following semantic patch:
// <smpl>
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);

@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;
// </smpl>

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 drivers/staging/wlan-ng/hfa384x_usb.c |    6 ++----
 drivers/staging/wlan-ng/prism2fw.c    |    3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c
index a6efc03..7843dfd 100644
--- a/drivers/staging/wlan-ng/hfa384x_usb.c
+++ b/drivers/staging/wlan-ng/hfa384x_usb.c
@@ -612,10 +612,8 @@ void hfa384x_destroy(hfa384x_t *hw)
 		hfa384x_drvr_stop(hw);
 	hw->state = HFA384x_STATE_PREINIT;
 
-	if (hw->scanresults) {
-		kfree(hw->scanresults);
-		hw->scanresults = NULL;
-	}
+	kfree(hw->scanresults);
+	hw->scanresults = NULL;
 
 	/* Now to clean out the auth queue */
 	while ((skb = skb_dequeue(&hw->authq)))
diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c
index fd5ddb2..729d03d 100644
--- a/drivers/staging/wlan-ng/prism2fw.c
+++ b/drivers/staging/wlan-ng/prism2fw.c
@@ -443,8 +443,7 @@ void free_chunks(struct imgchunk *fchunk, unsigned int *nfchunks)
 {
 	int i;
 	for (i = 0; i < *nfchunks; i++) {
-		if (fchunk[i].data != NULL)
-			kfree(fchunk[i].data);
+		kfree(fchunk[i].data);
 	}
 	*nfchunks = 0;
 	memset(fchunk, 0, sizeof(*fchunk));
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* Re: [PATCH 01/24] staging: ath6kl: Remove NULL check before kfree
  2011-03-13  5:28     ` [PATCH 01/24] staging: ath6kl: " Ilia Mirkin
  2011-03-13  5:28       ` [PATCH 02/24] staging: bcm: " Ilia Mirkin
@ 2011-03-14 17:47       ` Luis R. Rodriguez
  1 sibling, 0 replies; 35+ messages in thread
From: Luis R. Rodriguez @ 2011-03-14 17:47 UTC (permalink / raw)
  To: Ilia Mirkin, Naveen Singh; +Cc: Greg Kroah-Hartman, devel, linux-kernel

On Sat, Mar 12, 2011 at 9:28 PM, Ilia Mirkin <imirkin@alum.mit.edu> wrote:
> This patch was generated by the following semantic patch:
> // <smpl>
> @@ expression E; @@
> - if (E != NULL) { kfree(E); }
> + kfree(E);
>
> @@ expression E; @@
> - if (E != NULL) { kfree(E); E = NULL; }
> + kfree(E);
> + E = NULL;
> // </smpl>
>
> Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>

This is pretty awesome, thanks for using spatch and submitting stuff
for ath6kl :)

Acked-by: Luis R. Rodriguez <lrodriguez@atheros.com>

Greg, I'll rebase my next series on top of this patch.

  Luis

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 07/24] staging: hv: Remove NULL check before kfree
  2011-03-13  5:29                 ` [PATCH 07/24] staging: hv: " Ilia Mirkin
  2011-03-13  5:29                   ` [PATCH 08/24] staging: keucr: " Ilia Mirkin
@ 2011-03-14 19:00                   ` Greg KH
  1 sibling, 0 replies; 35+ messages in thread
From: Greg KH @ 2011-03-14 19:00 UTC (permalink / raw)
  To: Ilia Mirkin; +Cc: Greg Kroah-Hartman, devel, linux-kernel

On Sun, Mar 13, 2011 at 12:29:00AM -0500, Ilia Mirkin wrote:
> This patch was generated by the following semantic patch:
> // <smpl>
> @@ expression E; @@
> - if (E != NULL) { kfree(E); }
> + kfree(E);
> 
> @@ expression E; @@
> - if (E != NULL) { kfree(E); E = NULL; }
> + kfree(E);
> + E = NULL;
> // </smpl>
> 
> Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
> ---
>  drivers/staging/hv/channel_mgmt.c |    3 +--
>  drivers/staging/hv/connection.c   |    4 +---
>  drivers/staging/hv/hv_mouse.c     |   12 ++++--------
>  3 files changed, 6 insertions(+), 13 deletions(-)

Let me sync up with the other hyperv patches in my queue before applying
this one, don't worry, it's not lost...

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2011-03-14 19:14 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-22  8:53 [PATCH 1/2] staging: remove null checks before kfree Ilia Mirkin
2011-02-22  8:53 ` [PATCH 2/2] staging: remove null checks before kree(x); x = NULL; Ilia Mirkin
2011-02-22 14:54 ` [PATCH 1/2] staging: remove null checks before kfree Greg KH
2011-03-13  5:28   ` [PATCH 00/24] Remove NULL check " Ilia Mirkin
2011-03-13  5:28     ` [PATCH 01/24] staging: ath6kl: " Ilia Mirkin
2011-03-13  5:28       ` [PATCH 02/24] staging: bcm: " Ilia Mirkin
2011-03-13  5:28         ` [PATCH 03/24] staging: brcm80211: " Ilia Mirkin
2011-03-13  5:28           ` [PATCH 04/24] staging: comedi: " Ilia Mirkin
2011-03-13  5:28             ` [PATCH 05/24] staging: cx25821: " Ilia Mirkin
2011-03-13  5:28               ` [PATCH 06/24] staging: go7007: " Ilia Mirkin
2011-03-13  5:29                 ` [PATCH 07/24] staging: hv: " Ilia Mirkin
2011-03-13  5:29                   ` [PATCH 08/24] staging: keucr: " Ilia Mirkin
2011-03-13  5:29                     ` [PATCH 09/24] staging: line6: " Ilia Mirkin
2011-03-13  5:29                       ` [PATCH 10/24] staging: pohmelfs: " Ilia Mirkin
2011-03-13  5:29                         ` [PATCH 11/24] staging: rt2860: " Ilia Mirkin
2011-03-13  5:29                           ` [PATCH 12/24] staging: rtl8187se: " Ilia Mirkin
2011-03-13  5:29                             ` [PATCH 13/24] staging: rtl8192e: " Ilia Mirkin
2011-03-13  5:29                               ` [PATCH 14/24] staging: rtl8192u: " Ilia Mirkin
2011-03-13  5:29                                 ` [PATCH 15/24] staging: rtl8712: " Ilia Mirkin
2011-03-13  5:29                                   ` [PATCH 16/24] staging: serqt_usb2: " Ilia Mirkin
2011-03-13  5:29                                     ` [PATCH 17/24] staging: speakup: " Ilia Mirkin
2011-03-13  5:29                                       ` [PATCH 18/24] staging: tidspbridge: " Ilia Mirkin
2011-03-13  5:29                                         ` [PATCH 19/24] staging: usbip: " Ilia Mirkin
2011-03-13  5:29                                           ` [PATCH 20/24] staging: vme: " Ilia Mirkin
2011-03-13  5:29                                             ` [PATCH 21/24] staging: vt6655: " Ilia Mirkin
2011-03-13  5:29                                               ` [PATCH 22/24] staging: vt6656: " Ilia Mirkin
2011-03-13  5:29                                                 ` [PATCH 23/24] staging: winbond: " Ilia Mirkin
2011-03-13  5:29                                                   ` [PATCH 24/24] staging: wlan-ng: " Ilia Mirkin
2011-03-14 19:00                   ` [PATCH 07/24] staging: hv: " Greg KH
2011-03-14 17:47       ` [PATCH 01/24] staging: ath6kl: " Luis R. Rodriguez
2011-02-24 16:08 ` [PATCH 1/2] staging: remove null checks " Steven Rostedt
2011-02-24 17:06   ` Greg KH
2011-02-24 17:25     ` Steven Rostedt
2011-02-24 19:08       ` Ilia Mirkin
2011-02-24 19:25         ` Steven Rostedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.