public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] Staging: wilc1000: Remove null check before kfree
@ 2015-08-10  8:00 Shraddha Barke
  2015-08-10  8:00 ` [PATCH 2/3] Staging: lustre: libcfs: Remove unnecessary cast on void* Shraddha Barke
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Shraddha Barke @ 2015-08-10  8:00 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, Greg Kroah-Hartman, Benjamin Romer,
	Johnny Kim, Rachel Kim, HPDD-discuss, linux-kernel,
	linux-wireless
  Cc: Shraddha Barke

kfree on NULL pointer is a no-op.

This patch uses the following semantic patch to find such an instance
where NULL check is present before kfree.

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

Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
---
 drivers/staging/wilc1000/linux_wlan.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
index 3e55a8a..3dcd6e5 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -2343,8 +2343,7 @@ int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)
 
 done:
 
-	if (buff != NULL)
-		kfree(buff);
+	kfree(buff);
 
 	return s32Error;
 }
-- 
2.1.0


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

end of thread, other threads:[~2015-08-10 23:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-10  8:00 [PATCH 1/3] Staging: wilc1000: Remove null check before kfree Shraddha Barke
2015-08-10  8:00 ` [PATCH 2/3] Staging: lustre: libcfs: Remove unnecessary cast on void* Shraddha Barke
2015-08-10  8:00 ` [PATCH 3/3] Staging: unisys: Remove useless cast on void pointer Shraddha Barke
2015-08-10 23:30 ` [PATCH 1/3] Staging: wilc1000: Remove null check before kfree Dilger, Andreas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox