staging: rtl8188eu: core: Remove null check before kfree
authorTapasweni Pathak <tapaswenipathak@gmail.com>
Thu, 30 Oct 2014 15:38:09 +0000 (21:08 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 Oct 2014 20:12:05 +0000 (13:12 -0700)
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8188eu/core/rtw_cmd.c

index 7731cdb72b22f657be68e23fd648f76781a74c05..dd24138d13b15dbf266808a526ae1e4ef06d0503 100644 (file)
@@ -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;