public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8723bs: use kzalloc directly in _rtw_zmalloc
@ 2026-01-20  5:40 Minu Jin
  2026-01-20 15:38 ` Greg KH
  2026-01-22  6:20 ` Dan Carpenter
  0 siblings, 2 replies; 3+ messages in thread
From: Minu Jin @ 2026-01-20  5:40 UTC (permalink / raw)
  To: gregkh; +Cc: linux-staging, linux-kernel, Minu Jin

Replace kmalloc + memset with kzalloc for simpler and cleaner code.

Signed-off-by: Minu Jin <s9430939@naver.com>
---
 drivers/staging/rtl8723bs/os_dep/osdep_service.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/osdep_service.c b/drivers/staging/rtl8723bs/os_dep/osdep_service.c
index a00f9f0c85c5..be46132a533a 100644
--- a/drivers/staging/rtl8723bs/os_dep/osdep_service.c
+++ b/drivers/staging/rtl8723bs/os_dep/osdep_service.c
@@ -24,12 +24,7 @@ void *_rtw_malloc(u32 sz)
 
 void *_rtw_zmalloc(u32 sz)
 {
-	void *pbuf = _rtw_malloc(sz);
-
-	if (pbuf)
-		memset(pbuf, 0, sz);
-
-	return pbuf;
+	return kzalloc(sz, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
 }
 
 inline struct sk_buff *_rtw_skb_alloc(u32 sz)
-- 
2.43.0


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

* Re: [PATCH] staging: rtl8723bs: use kzalloc directly in _rtw_zmalloc
  2026-01-20  5:40 [PATCH] staging: rtl8723bs: use kzalloc directly in _rtw_zmalloc Minu Jin
@ 2026-01-20 15:38 ` Greg KH
  2026-01-22  6:20 ` Dan Carpenter
  1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2026-01-20 15:38 UTC (permalink / raw)
  To: Minu Jin; +Cc: linux-staging, linux-kernel

On Tue, Jan 20, 2026 at 02:40:36PM +0900, Minu Jin wrote:
> Replace kmalloc + memset with kzalloc for simpler and cleaner code.
> 
> Signed-off-by: Minu Jin <s9430939@naver.com>
> ---
>  drivers/staging/rtl8723bs/os_dep/osdep_service.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/rtl8723bs/os_dep/osdep_service.c b/drivers/staging/rtl8723bs/os_dep/osdep_service.c
> index a00f9f0c85c5..be46132a533a 100644
> --- a/drivers/staging/rtl8723bs/os_dep/osdep_service.c
> +++ b/drivers/staging/rtl8723bs/os_dep/osdep_service.c
> @@ -24,12 +24,7 @@ void *_rtw_malloc(u32 sz)
>  
>  void *_rtw_zmalloc(u32 sz)
>  {
> -	void *pbuf = _rtw_malloc(sz);
> -
> -	if (pbuf)
> -		memset(pbuf, 0, sz);
> -
> -	return pbuf;
> +	return kzalloc(sz, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);

So there is now no more calles to _rtw_malloc(), so why is it left in
here?  Oh wait, it's a wrapper for nothing?  Odd.

And the in_interrupt() check really doesn't work, that shouldn't be
used.

And finally, try to just replace the callers with the real call to
kzalloc, don't propagate this mess any more, the wrapper needs to be
removed entirely.

Same for probably all functions in this file, right?

thanks,

greg k-h

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

* Re: [PATCH] staging: rtl8723bs: use kzalloc directly in _rtw_zmalloc
  2026-01-20  5:40 [PATCH] staging: rtl8723bs: use kzalloc directly in _rtw_zmalloc Minu Jin
  2026-01-20 15:38 ` Greg KH
@ 2026-01-22  6:20 ` Dan Carpenter
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2026-01-22  6:20 UTC (permalink / raw)
  To: Minu Jin; +Cc: gregkh, linux-staging, linux-kernel

On Tue, Jan 20, 2026 at 02:40:36PM +0900, Minu Jin wrote:
> Replace kmalloc + memset with kzalloc for simpler and cleaner code.
> 
> Signed-off-by: Minu Jin <s9430939@naver.com>
> ---
>  drivers/staging/rtl8723bs/os_dep/osdep_service.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/rtl8723bs/os_dep/osdep_service.c b/drivers/staging/rtl8723bs/os_dep/osdep_service.c
> index a00f9f0c85c5..be46132a533a 100644
> --- a/drivers/staging/rtl8723bs/os_dep/osdep_service.c
> +++ b/drivers/staging/rtl8723bs/os_dep/osdep_service.c
> @@ -24,12 +24,7 @@ void *_rtw_malloc(u32 sz)
>  
>  void *_rtw_zmalloc(u32 sz)
>  {
> -	void *pbuf = _rtw_malloc(sz);
> -
> -	if (pbuf)
> -		memset(pbuf, 0, sz);
> -
> -	return pbuf;
> +	return kzalloc(sz, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);

This in_interrupt() is garbage.  We should use GFP_ATOMIC if we
are in an interrupt handler or if holding a spinlock.  The right
thing to do is review all the callers and figure out whether
GFP_ATOMIC or GFP_KERNEL is appropriate.

regards,
dan carpenter


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

end of thread, other threads:[~2026-01-22  6:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-20  5:40 [PATCH] staging: rtl8723bs: use kzalloc directly in _rtw_zmalloc Minu Jin
2026-01-20 15:38 ` Greg KH
2026-01-22  6:20 ` Dan Carpenter

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