public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] staging: rtl8712: use kmalloc_array
@ 2024-09-22 19:41 Tudor Gheorghiu
  2024-09-22 20:46 ` Philipp Hortmann
  0 siblings, 1 reply; 2+ messages in thread
From: Tudor Gheorghiu @ 2024-09-22 19:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Philipp Hortmann
  Cc: Larry Finger, Florian Schilhabel,
	Linux Driver Project Developer List, linux-staging, linux-kernel

Adhere to Linux kernel coding style.

Reported by checkpatch:

WARNING: Prefer kmalloc_array over kmalloc with multiply
+       pxmitpriv->pxmitbuf = kmalloc(NR_XMITBUFF * sizeof(struct xmit_buf), GFP_ATOMIC);

Signed-off-by: Tudor Gheorghiu <tudor.reda@gmail.com>
---
v2: Update patch description
---
 drivers/staging/rtl8712/rtl871x_xmit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8712/rtl871x_xmit.c b/drivers/staging/rtl8712/rtl871x_xmit.c
index 408616e9afcf..a0f29fab3dce 100644
--- a/drivers/staging/rtl8712/rtl871x_xmit.c
+++ b/drivers/staging/rtl8712/rtl871x_xmit.c
@@ -117,7 +117,7 @@ int _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv,
 	/*init xmit_buf*/
 	_init_queue(&pxmitpriv->free_xmitbuf_queue);
 	_init_queue(&pxmitpriv->pending_xmitbuf_queue);
-	pxmitpriv->pxmitbuf = kmalloc(NR_XMITBUFF * sizeof(struct xmit_buf), GFP_ATOMIC);
+	pxmitpriv->pxmitbuf = kmalloc_array(NR_XMITBUFF, sizeof(struct xmit_buf), GFP_ATOMIC);
 	if (!pxmitpriv->pxmitbuf)
 		goto clean_up_frame_buf;
 	pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf;
-- 
2.43.0


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

* Re: [PATCH v2] staging: rtl8712: use kmalloc_array
  2024-09-22 19:41 [PATCH v2] staging: rtl8712: use kmalloc_array Tudor Gheorghiu
@ 2024-09-22 20:46 ` Philipp Hortmann
  0 siblings, 0 replies; 2+ messages in thread
From: Philipp Hortmann @ 2024-09-22 20:46 UTC (permalink / raw)
  To: Tudor Gheorghiu, Greg Kroah-Hartman
  Cc: Larry Finger, Florian Schilhabel,
	Linux Driver Project Developer List, linux-staging, linux-kernel

On 9/22/24 9:41 PM, Tudor Gheorghiu wrote:
> Adhere to Linux kernel coding style.
> 
> Reported by checkpatch:
> 
> WARNING: Prefer kmalloc_array over kmalloc with multiply
> +       pxmitpriv->pxmitbuf = kmalloc(NR_XMITBUFF * sizeof(struct xmit_buf), GFP_ATOMIC);
> 
> Signed-off-by: Tudor Gheorghiu <tudor.reda@gmail.com>
> ---
> v2: Update patch description
> ---
>   drivers/staging/rtl8712/rtl871x_xmit.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/rtl8712/rtl871x_xmit.c b/drivers/staging/rtl8712/rtl871x_xmit.c
> index 408616e9afcf..a0f29fab3dce 100644
> --- a/drivers/staging/rtl8712/rtl871x_xmit.c
> +++ b/drivers/staging/rtl8712/rtl871x_xmit.c
> @@ -117,7 +117,7 @@ int _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv,
>   	/*init xmit_buf*/
>   	_init_queue(&pxmitpriv->free_xmitbuf_queue);
>   	_init_queue(&pxmitpriv->pending_xmitbuf_queue);
> -	pxmitpriv->pxmitbuf = kmalloc(NR_XMITBUFF * sizeof(struct xmit_buf), GFP_ATOMIC);
> +	pxmitpriv->pxmitbuf = kmalloc_array(NR_XMITBUFF, sizeof(struct xmit_buf), GFP_ATOMIC);
>   	if (!pxmitpriv->pxmitbuf)
>   		goto clean_up_frame_buf;
>   	pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf;

Reviewed-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>


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

end of thread, other threads:[~2024-09-22 20:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-22 19:41 [PATCH v2] staging: rtl8712: use kmalloc_array Tudor Gheorghiu
2024-09-22 20:46 ` Philipp Hortmann

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