staging: r8188eu: proper error handling in rtw_init_drv_sw
authorVihas Makwana <makvihas@gmail.com>
Wed, 9 Mar 2022 20:50:47 +0000 (02:20 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 15 Mar 2022 14:18:32 +0000 (15:18 +0100)
commit1868755c9078cda1a3a4abd866edd42f9a46b1ed
tree04e9023a7071a3108901565a7b350d03870d6e52
parent57a42b4d73f9d6f6fbe8b11f22453e1bc3183648
staging: r8188eu: proper error handling in rtw_init_drv_sw

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.

Fixes: 2b42bd58b321 ("staging: r8188eu: introduce new os_dep dir for RTL8188eu driver")
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Pavel Skripkin <paskripkin@gmail.com>
Signed-off-by: Vihas Makwana <makvihas@gmail.com>
Link: https://lore.kernel.org/r/20220309205047.45981-3-makvihas@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/r8188eu/os_dep/os_intfs.c