staging: rtl8723bs: hal: Remove NULL check before kfree
authorSimran Singhal <singhalsimran0@gmail.com>
Thu, 26 Mar 2020 13:28:23 +0000 (18:58 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 26 Mar 2020 14:47:26 +0000 (15:47 +0100)
NULL check before kfree is unnecessary so remove it.

The following Coccinelle script was used to detect this:
@@ expression E; @@
- if (E != NULL) { kfree(E); }
+ kfree(E);
@@ expression E; @@
- if (E != NULL) { kfree(E); E = NULL; }
+ kfree(E);
+ E = NULL;

Signed-off-by: Simran Singhal <singhalsimran0@gmail.com>
Link: https://lore.kernel.org/r/20200326132823.GA18625@simran-Inspiron-5558
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c

index 2b375e75be5048bc96001fc9cda26ada5b7b8a7d..c3051ebaeb780ee8ee06ba77ceeafd1840183c04 100644 (file)
@@ -480,10 +480,8 @@ initbuferror:
                precvpriv->precv_buf = NULL;
        }
 
-       if (precvpriv->pallocated_recv_buf) {
-               kfree(precvpriv->pallocated_recv_buf);
-               precvpriv->pallocated_recv_buf = NULL;
-       }
+       kfree(precvpriv->pallocated_recv_buf);
+       precvpriv->pallocated_recv_buf = NULL;
 
 exit:
        return res;
@@ -518,8 +516,6 @@ void rtl8723bs_free_recv_priv(struct adapter *padapter)
                precvpriv->precv_buf = NULL;
        }
 
-       if (precvpriv->pallocated_recv_buf) {
-               kfree(precvpriv->pallocated_recv_buf);
-               precvpriv->pallocated_recv_buf = NULL;
-       }
+       kfree(precvpriv->pallocated_recv_buf);
+       precvpriv->pallocated_recv_buf = NULL;
 }