public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] rtl8723bs: fix memory leak on failure path
@ 2026-01-13  9:17 Diksha Kumari
  2026-01-14 10:53 ` Mukesh Kumar Chaurasiya
  0 siblings, 1 reply; 2+ messages in thread
From: Diksha Kumari @ 2026-01-13  9:17 UTC (permalink / raw)
  To: gregkh, johannes.berg, straube.linux, knavaneeth786,
	dan.carpenter, quic_rdevanat, arend.vanspriel, linux-staging
  Cc: Diksha Kumari

cfg80211_inform_bss_frame() may return NULL on failure. In that case,
the allocated buffer 'buf' is not freed and the function returns early,
leading to potential memory leak.
Fix this by ensuring that 'buf' is freed on both success and failure paths.

Signed-off-by: Diksha Kumari <dikshakdevgan@gmail.com>
---
 drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index 60edeae1cffe..476ab055e53e 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
@@ -315,9 +315,10 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wl
 					len, notify_signal, GFP_ATOMIC);
 
 	if (unlikely(!bss))
-		goto exit;
+		goto free_buf;
 
 	cfg80211_put_bss(wiphy, bss);
+free_buf:
 	kfree(buf);
 
 exit:
-- 
2.34.1


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

* Re: [PATCH] rtl8723bs: fix memory leak on failure path
  2026-01-13  9:17 [PATCH] rtl8723bs: fix memory leak on failure path Diksha Kumari
@ 2026-01-14 10:53 ` Mukesh Kumar Chaurasiya
  0 siblings, 0 replies; 2+ messages in thread
From: Mukesh Kumar Chaurasiya @ 2026-01-14 10:53 UTC (permalink / raw)
  To: Diksha Kumari
  Cc: gregkh, johannes.berg, straube.linux, knavaneeth786,
	dan.carpenter, quic_rdevanat, arend.vanspriel, linux-staging

On Tue, Jan 13, 2026 at 02:47:12PM +0530, Diksha Kumari wrote:
> cfg80211_inform_bss_frame() may return NULL on failure. In that case,
> the allocated buffer 'buf' is not freed and the function returns early,
> leading to potential memory leak.
> Fix this by ensuring that 'buf' is freed on both success and failure paths.
> 
> Signed-off-by: Diksha Kumari <dikshakdevgan@gmail.com>
> ---
>  drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
> index 60edeae1cffe..476ab055e53e 100644
> --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
> +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
> @@ -315,9 +315,10 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wl
>  					len, notify_signal, GFP_ATOMIC);
>  
>  	if (unlikely(!bss))
> -		goto exit;
> +		goto free_buf;
>  
>  	cfg80211_put_bss(wiphy, bss);
> +free_buf:
>  	kfree(buf);
>  
>  exit:
> -- 
> 2.34.1
> 
LGTM

Reviewed-by: Mukesh Kumar Chaurasiya <mkchauras@linux.ibm.com>

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

end of thread, other threads:[~2026-01-14 10:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-13  9:17 [PATCH] rtl8723bs: fix memory leak on failure path Diksha Kumari
2026-01-14 10:53 ` Mukesh Kumar Chaurasiya

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