Skip to contentSkip to conversation

staging: rtl8723bs: fix copy of overlapping memory

PATCH In review Colin King 2 participants 2 messages Jan 26, 2020 – Jan 27, 2020

Subsystems (2)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 staging: rtl8723bs: fix copy of overlapping memory

From: Colin Ian King <[email protected]>

Currently the rtw_sprintf prints the contents of thread_name onto thread_name and this can lead to a potential copy of a string over itself. Avoid this by printing the literal string RTWHALXT instread of the contents of thread_name.

Addresses-Coverity: ("copy of overlapping memory")

Fixes 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver")
---
 drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +2 -3
index b44e902ed338..890e0ecbeb2e 100644
@@ -476,14 +476,13 @@ int rtl8723bs_xmit_thread(void *context)
 	s32 ret;
 	struct adapter *padapter;
 	struct xmit_priv *pxmitpriv;
-	u8 thread_name[20] = "RTWHALXT";
-
+	u8 thread_name[20];
 
 	ret = _SUCCESS;
 	padapter = context;
 	pxmitpriv = &padapter->xmitpriv;
 
-	rtw_sprintf(thread_name, 20, "%s-"ADPT_FMT, thread_name, ADPT_ARG(padapter));
+	rtw_sprintf(thread_name, 20, "RTWHALXT-" ADPT_FMT, ADPT_ARG(padapter));
 	thread_enter(thread_name);
 
 	DBG_871X("start "FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(padapter));
Signature · 1 line
2.24.0
Reviewed-by on v1 1/1
#1 lore raw

HI,

Quoted 10 lines · Colin King

From: Colin Ian King <[email protected]>

Currently the rtw_sprintf prints the contents of thread_name onto thread_name and this can lead to a potential copy of a string over itself. Avoid this by printing the literal string RTWHALXT instread of the contents of thread_name.

Addresses-Coverity: ("copy of overlapping memory")

Fixes 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver")

Patch looks good to me:

Regards,

Hans

Quoted 26 lines
---
  drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +2 -3
index b44e902ed338..890e0ecbeb2e 100644
@@ -476,14 +476,13 @@ int rtl8723bs_xmit_thread(void *context)
  	s32 ret;
  	struct adapter *padapter;
  	struct xmit_priv *pxmitpriv;
-	u8 thread_name[20] = "RTWHALXT";
-
+	u8 thread_name[20];
 
  	ret = _SUCCESS;
  	padapter = context;
  	pxmitpriv = &padapter->xmitpriv;
 
-	rtw_sprintf(thread_name, 20, "%s-"ADPT_FMT, thread_name, ADPT_ARG(padapter));
+	rtw_sprintf(thread_name, 20, "RTWHALXT-" ADPT_FMT, ADPT_ARG(padapter));
  	thread_enter(thread_name);
 
  	DBG_871X("start "FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(padapter));