Re: [PATCH] staging: rtl8723bs: Use pointer type in vzalloc()

From: Greg KH

Date: Tue Jul 28 2026 - 03:39:45 EST


On Wed, Jul 22, 2026 at 03:18:25PM +0200, Patryk Gawroński wrote:
> Update the memory allocation in _rtw_init_sta_priv() to use
> sizeof(*pstapriv->pallocated_stainfo_buf) instead of explicitly
> passing sizeof(struct sta_info).
>
> This resolves the following checkpatch warning:
> "Prefer vzalloc(sizeof(*pstapriv->pallocated_stainfo_buf)...) over
> vzalloc(sizeof(struct sta_info)...)"
>
> Using the pointer type is preferred in the kernel as it ensures the
> allocated size remains correct even if the pointer's underlying type
> changes in the future. The allocation was also split across multiple
> lines to comply with column length limits.
>
> Signed-off-by: Patryk Gawroński <gawronski1.6@xxxxxxxxx>
> ---
> 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 aea660f27959..0758d0540f4b 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);

You just broke the driver as the math here is now not the same.

Hint, look at what pallocated_stainfo_buf really is. It's not a pointer
to a struct at all, right?

thanks,

greg k-h