Staging: rtl8723bs: Do not check for NOT NULL before kfree()
authorShreeya Patel <shreeya.patel23498@gmail.com>
Tue, 19 Dec 2017 19:07:45 +0000 (00:37 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 21 Dec 2017 17:22:07 +0000 (18:22 +0100)
Do not check for NOT NULL before calling kfree because
if the pointer is NULL, no action occurs.
Done using the following semantic patch by coccinelle.

@@
expression ptr;
@@

- if (ptr != NULL)
  kfree(ptr);

Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8723bs/core/rtw_cmd.c

index 9ac2dea6dff1cfb3dc1a1255532c76b9d0b5ae85..af0a9e0a00dfd2a4da3fed50fa472cbc4cfd5947 100644 (file)
@@ -846,9 +846,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;
 
                RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("rtw_joinbss_cmd :psecnetwork == NULL!!!\n"));