Skip to contentSkip to conversation

staging: rtl8723bs: remove redundant kfree check in rtw_xmit.c

PATCH In review Andrezinrc 2 participants 2 messages Jun 19 Staging

lore
Share & tools
lore

Andrezinrc

author
#0 lore raw

PATCH 1/1 staging: rtl8723bs: remove redundant kfree check in rtw_xmit.c

Remove the redundant null check before calling kfree. ccheckpatch reminds us that kfree(NULL) is safe and this check is not required.

---
 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 7bce0343d..92e818705 100644
@@ -1736,10 +1736,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.43.0
#1 lore raw
Quoted 13 lines · Andrezinrc

Remove the redundant null check before calling kfree. ccheckpatch reminds us that kfree(NULL) is safe and this check is not required.

---
 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 7bce0343d..92e818705 100644

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

Quoted 9 lines
drivers/staging/rtl8723bs/core/rtw_xmit.c +2 -3
@@ -1736,10 +1736,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;
-	}

The code was more readable before.

regards,
dan carpenter