public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8723bs: Break long lines in rtw_sta_mgt.c
@ 2026-03-19  2:48 Malavya Raval
  2026-03-19  8:39 ` Luka Gejak
  0 siblings, 1 reply; 5+ messages in thread
From: Malavya Raval @ 2026-03-19  2:48 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-staging, linux-kernel, MalavyaRaval

From: MalavyaRaval <malavyaraval@gmail.com>

Split long lines in rtw_sta_mgt.c to adhere to kernel coding style.

Signed-off-by: MalavyaRaval <malavyaraval@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_sta_mgt.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
index 9d222ae87d79..40a1dc9658c8 100644
--- a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
@@ -54,7 +54,8 @@ u32 _rtw_init_sta_priv(struct	sta_priv *pstapriv)
 	struct sta_info *psta;
 	s32 i;
 
-	pstapriv->pallocated_stainfo_buf = vzalloc(sizeof(struct sta_info) * NUM_STA + 4);
+	pstapriv->pallocated_stainfo_buf = vzalloc(sizeof(*pstapriv->pallocated_stainfo_buf) *
+						    NUM_STA + 4);
 
 	if (!pstapriv->pallocated_stainfo_buf)
 		return _FAIL;
@@ -105,7 +106,8 @@ u32 _rtw_init_sta_priv(struct	sta_priv *pstapriv)
 
 inline int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta)
 {
-	int offset = (((u8 *)sta) - stapriv->pstainfo_buf) / sizeof(struct sta_info);
+	int offset = (((u8 *)sta) - stapriv->pstainfo_buf) /
+		     sizeof(struct sta_info);
 
 	return offset;
 }
-- 
2.43.0


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

* Re: [PATCH] staging: rtl8723bs: Break long lines in rtw_sta_mgt.c
  2026-03-19  2:48 [PATCH] staging: rtl8723bs: Break long lines in rtw_sta_mgt.c Malavya Raval
@ 2026-03-19  8:39 ` Luka Gejak
  0 siblings, 0 replies; 5+ messages in thread
From: Luka Gejak @ 2026-03-19  8:39 UTC (permalink / raw)
  To: Malavya Raval; +Cc: Greg Kroah-Hartman, linux-staging, linux-kernel, Luka Gejak

Hi Malavya,

Thanks for the patch!

I have a concern regarding the first hunk of this change:

> -	pstapriv->pallocated_stainfo_buf = vzalloc(sizeof(struct sta_info) * NUM_STA + 4);
> +	pstapriv->pallocated_stainfo_buf = vzalloc(sizeof(*pstapriv->pallocated_stainfo_buf) *
> +						    NUM_STA + 4);					    

You've changed the logic from taking the size of 'struct sta_info' to 
the size of the dereferenced pointer 
'*pstapriv->pallocated_stainfo_buf'.


Firstly: In this driver, 'pallocated_stainfo_buf' is a u8 pointer. This 
means sizeof(*ptr) will return 1, whereas 'struct sta_info' is much 
larger. This will lead to a significantly smaller memory allocation 
than intended and cause a buffer overflow.

If you want to use the preferred 'sizeof(*ptr)' style, you should use 
the pointer that actually represents the structure array, or stick to 
the original 'struct sta_info' and just wrap the line.

Secondly: For a v2, when splitting the line, 'NUM_STA' should be 
vertically aligned with the start of the 'sizeof' expression on the 
line above. Right now, the indentation looks a bit off.

Also, for a v2, please ensure your subject line starts with a lowercase 
letter after the prefix: "staging: rtl8723bs: break long lines..."

Best regards,
Luka Gejak

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

* [PATCH] staging: rtl8723bs: break long lines in rtw_sta_mgt.c
@ 2026-03-19 17:42 MalavyaRaval
  2026-03-19 18:58 ` Ethan Tidmore
  0 siblings, 1 reply; 5+ messages in thread
From: MalavyaRaval @ 2026-03-19 17:42 UTC (permalink / raw)
  To: gregkh, linux-staging, linux-kernel; +Cc: luka.gejak, MalavyaRaval

The original patch attempted to use the preferred sizeof(*ptr) style,
but since the target variable is a u8 pointer, this caused a buffer
overflow. Reverting to sizeof(struct sta_info) ensures the correct
allocation size while satisfying the line-splitting requirement.

Signed-off-by: MalavyaRaval <malavyaraval@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_sta_mgt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
index 07a6db1d2317..867877413859 100644
--- a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c
@@ -54,7 +54,8 @@ u32 _rtw_init_sta_priv(struct	sta_priv *pstapriv)
 	struct sta_info *psta;
 	s32 i;
 
-	pstapriv->pallocated_stainfo_buf = vzalloc(sizeof(struct sta_info) * NUM_STA + 4);
+	pstapriv->pallocated_stainfo_buf = vzalloc(sizeof(struct sta_info) *
+						   NUM_STA + 4);
 
 	if (!pstapriv->pallocated_stainfo_buf)
 		return _FAIL;
-- 
2.43.0


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

* Re: [PATCH] staging: rtl8723bs: break long lines in rtw_sta_mgt.c
  2026-03-19 17:42 [PATCH] staging: rtl8723bs: break " MalavyaRaval
@ 2026-03-19 18:58 ` Ethan Tidmore
  2026-03-19 18:59   ` Ethan Tidmore
  0 siblings, 1 reply; 5+ messages in thread
From: Ethan Tidmore @ 2026-03-19 18:58 UTC (permalink / raw)
  To: MalavyaRaval, gregkh, linux-staging, linux-kernel; +Cc: luka.gejak

On Thu Mar 19, 2026 at 12:42 PM CDT, MalavyaRaval wrote:
> The original patch attempted to use the preferred sizeof(*ptr) style,
> but since the target variable is a u8 pointer, this caused a buffer
> overflow. Reverting to sizeof(struct sta_info) ensures the correct
> allocation size while satisfying the line-splitting requirement.
>
> Signed-off-by: MalavyaRaval <malavyaraval@gmail.com>

You need to put FirstName LastName <email>.

...

> -	pstapriv->pallocated_stainfo_buf = vzalloc(sizeof(struct sta_info) * NUM_STA + 4);
> +	pstapriv->pallocated_stainfo_buf = vzalloc(sizeof(struct sta_info) *
> +						   NUM_STA + 4);

This just makes the code harder to read.

Thanks,

ET

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

* Re: [PATCH] staging: rtl8723bs: break long lines in rtw_sta_mgt.c
  2026-03-19 18:58 ` Ethan Tidmore
@ 2026-03-19 18:59   ` Ethan Tidmore
  0 siblings, 0 replies; 5+ messages in thread
From: Ethan Tidmore @ 2026-03-19 18:59 UTC (permalink / raw)
  To: Ethan Tidmore, MalavyaRaval, gregkh, linux-staging, linux-kernel
  Cc: luka.gejak

On Thu Mar 19, 2026 at 1:58 PM CDT, Ethan Tidmore wrote:
> On Thu Mar 19, 2026 at 12:42 PM CDT, MalavyaRaval wrote:
>> The original patch attempted to use the preferred sizeof(*ptr) style,
>> but since the target variable is a u8 pointer, this caused a buffer
>> overflow. Reverting to sizeof(struct sta_info) ensures the correct
>> allocation size while satisfying the line-splitting requirement.

Also this commit message is totally unrelated to the change.

Thanks,

ET

>>
>> Signed-off-by: MalavyaRaval <malavyaraval@gmail.com>

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

end of thread, other threads:[~2026-03-19 18:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-19  2:48 [PATCH] staging: rtl8723bs: Break long lines in rtw_sta_mgt.c Malavya Raval
2026-03-19  8:39 ` Luka Gejak
  -- strict thread matches above, loose matches on Subject: below --
2026-03-19 17:42 [PATCH] staging: rtl8723bs: break " MalavyaRaval
2026-03-19 18:58 ` Ethan Tidmore
2026-03-19 18:59   ` Ethan Tidmore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox