linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8723bs: fix copy of overlapping memory
@ 2020-01-26 22:05 Colin King
  2020-01-27 14:09 ` Hans de Goede
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2020-01-26 22:05 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Hans de Goede, devel; +Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

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")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
index b44e902ed338..890e0ecbeb2e 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
@@ -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));
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] staging: rtl8723bs: fix copy of overlapping memory
  2020-01-26 22:05 [PATCH] staging: rtl8723bs: fix copy of overlapping memory Colin King
@ 2020-01-27 14:09 ` Hans de Goede
  0 siblings, 0 replies; 2+ messages in thread
From: Hans de Goede @ 2020-01-27 14:09 UTC (permalink / raw)
  To: Colin King, Greg Kroah-Hartman, devel; +Cc: kernel-janitors, linux-kernel

HI,

On 26-01-2020 23:05, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> 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")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Patch looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans


> ---
>   drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
> index b44e902ed338..890e0ecbeb2e 100644
> --- a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
> +++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
> @@ -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));
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-01-27 14:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-26 22:05 [PATCH] staging: rtl8723bs: fix copy of overlapping memory Colin King
2020-01-27 14:09 ` Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).