The code inside rtw_init_drv_sw() calls various init functions to
populate the padapter structure and checks for their return values
respectively.
But if one of the functions in middle fails then it simply returns
_FAIL instead of proper logging and calling freeing counterparts
of previous init functions.
This leads to various memory leaks and can be found in
/sys/kernel/debug/kmemleak if kernel is compiled with DEBUG_KMEMLEAK=y.
Fix this and keep the success and error separate.
Signed-off-by: Vihas Makwana <makvihas@xxxxxxxxx>
---
Tested on Comfast CF-WU810N RTL8188EUS wireless adapter.
This patch depends on "[PATCH 1/2] staging: r8188eu: call _cancel_timer_ex from
_rtw_free_recv_priv"
---
drivers/staging/r8188eu/os_dep/os_intfs.c | 60 ++++++++++++++++++-----
1 file changed, 47 insertions(+), 13 deletions(-)
diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c
index 197568422..6279bba07 100644
--- a/drivers/staging/r8188eu/os_dep/os_intfs.c
+++ b/drivers/staging/r8188eu/os_dep/os_intfs.c
@@ -469,32 +469,46 @@ u8 rtw_reset_drv_sw(struct adapter *padapter)
u8 rtw_init_drv_sw(struct adapter *padapter)
{
- if ((rtw_init_cmd_priv(&padapter->cmdpriv)) == _FAIL)
+ if ((rtw_init_cmd_priv(&padapter->cmdpriv)) == _FAIL) {
+ pr_err("rtw_init_cmd_priv failed\n");
return _FAIL;
+ }
padapter->cmdpriv.padapter = padapter;