Skip to contentSkip to conversation

staging: rtl8723bs: remove unnecessary NULL check before kfree

PATCH In review Callan McClish 2 participants 2 messages Sep 20 – Sep 21 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rtl8723bs: remove unnecessary NULL check before kfree

kfree(NULL) is a safe operation and an explicit NULL check is redundant, therefore it should be omitted.
Detected by checkpatch.

---
 drivers/staging/rtl8723bs/core/rtw_xmit.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/rtl8723bs/core/rtw_xmit.c +2 -3
index 81d9e713fc12..6aaa07813d46 100644
@@ -1748,10 +1748,9 @@ s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitfram
 		pxmitframe->pkt = NULL;
 	}
 
-	if (pxmitframe->alloc_addr) {
-		kfree(pxmitframe->alloc_addr);
+	kfree(pxmitframe->alloc_addr);
+	if (pxmitframe->alloc_addr)
 		goto check_pkt_complete;
-	}
 
 	if (pxmitframe->ext_tag == 0)
 		queue = &pxmitpriv->free_xmit_queue;
Signature · 1 line
2.55.0
#1 lore raw
Quoted 14 lines · Callan McClish

kfree(NULL) is a safe operation and an explicit NULL check is redundant, therefore it should be omitted.
Detected by checkpatch.

---
 drivers/staging/rtl8723bs/core/rtw_xmit.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/rtl8723bs/core/rtw_xmit.c +0 -0
index 81d9e713fc12..6aaa07813d46 100644

drivers/staging/rtl8723bs/core/rtw_xmit.c s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitfram · line 1754

Quoted 9 lines
drivers/staging/rtl8723bs/core/rtw_xmit.c +2 -3
@@ -1748,10 +1748,9 @@ s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitfram
 		pxmitframe->pkt = NULL;
 	}
 
-	if (pxmitframe->alloc_addr) {
-		kfree(pxmitframe->alloc_addr);
+	kfree(pxmitframe->alloc_addr);
+	if (pxmitframe->alloc_addr)
 		goto check_pkt_complete;
-	}

Do a search on lore before sending patches... We need to add some new drivers to staging because people seem to be doing the same things over and over...

https://lore.kernel.org/all/[email protected]/

I guess this still works as a lesson in ignoring checkpatch and being skeptical of advice from tools...

regards,
dan carpenter