rtl8723bs: fix memory leak on failure path
PATCH 1/1 rtl8723bs: fix memory leak on failure path
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 <[email protected]>
--- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +2 -1
@@ -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:
Signature · 1 line
2.34.1
Quoted 29 lines · 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 <[email protected]>--- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +2
-1@@ -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:Signature · 1 line
2.34.1
LGTM
Reviewed-by Mukesh Kumar Chaurasiya <[email protected]>