Skip to contentSkip to conversation

staging: rtl8192e: Remove NULL test before vfree

PATCH In review Bhaktipriya Shridhar 2 participants 2 messages Feb 28, 2016 – Mar 11, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH v3 4/4 staging: rtl8192e: Remove NULL test before vfree

vfree frees the virtually continuous memory area starting at addr. If addr is NULL, no operation is performed. So NULL test is not needed before vfree.

This was done using Coccinelle:

@@
expression x;
@@
-if (x != NULL)

    vfree(x);

@@
expression x;
@@

-if (x != NULL) {
vfree(x);
x = NULL;
-}

---
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/rtl8192e/rtl8192e/rtl_core.c +2 -4
index 0b06482..6811702 100644
@@ -2697,10 +2697,8 @@ static void _rtl92e_pci_disconnect(struct pci_dev *pdev)
 		priv->polling_timer_on = 0;
 		_rtl92e_down(dev, true);
 		rtl92e_dm_deinit(dev);
-		if (priv->pFirmware) {
-			vfree(priv->pFirmware);
-			priv->pFirmware = NULL;
-		}
+		vfree(priv->pFirmware);
+		priv->pFirmware = NULL;
 		destroy_workqueue(priv->priv_wq);
 		_rtl92e_free_rx_ring(dev);
 		for (i = 0; i < MAX_TX_QUEUE_COUNT; i++)

--
2.1.4

maintainer
#1 lore raw
Quoted 21 lines · Bhaktipriya Shridhar

vfree frees the virtually continuous memory area starting at addr. If addr is NULL, no operation is performed. So NULL test is not needed before vfree.

This was done using Coccinelle:

@@
expression x;
@@
-if (x != NULL)

    vfree(x);

@@
expression x;
@@

(quoted diff) +0 -2
-if (x != NULL) {
   vfree(x);
   x = NULL;
-}
Quoted 4 lines
---
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Patch does not apply :(