[OPW,kernel,RESEND,v3] staging: rtl8188eu: core: Remove null check before kfree
diff mbox

Message ID 20141030153809.GA5098@kt-Inspiron-3542
State New, archived
Headers show

Commit Message

Tapasweni Pathak Oct. 30, 2014, 3:38 p.m. UTC
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>

Build tested it.

Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
---
Note:
This patch was sent in a patchset. In the same patch improvement
of cleanup code was done. Separated both the changes in two
separate patches and resending.
Suggested by: Julia Lawall <julia.lawall@lip6.fr>

 drivers/staging/rtl8188eu/core/rtw_cmd.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--
1.7.9.5

Patch
diff mbox

diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c
index 7731cdb..dd24138 100644
--- a/drivers/staging/rtl8188eu/core/rtw_cmd.c
+++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c
@@ -433,8 +433,7 @@  u8 rtw_joinbss_cmd(struct adapter  *padapter, struct wlan_network *pnetwork)

 	psecnetwork = (struct wlan_bssid_ex *)&psecuritypriv->sec_bss;
 	if (psecnetwork == NULL) {
-		if (pcmd != NULL)
-			kfree(pcmd);
+		kfree(pcmd);

 		res = _FAIL;