diff mbox series

[net,4/5] wifi: rtlwifi: fix init_sw_vars leak when probe fails

Message ID 20241107133322.855112-5-cascardo@igalia.com (mailing list archive)
State New
Delegated to: Ping-Ke Shih
Headers show
Series wifi: rtlwifi: usb probe error path fixes | expand

Commit Message

Thadeu Lima de Souza Cascardo Nov. 7, 2024, 1:33 p.m. UTC
If ieee80211_register_hw fails, the memory allocated for the firmware will
not be released. Call deinit_sw_vars as the function that undoes the
allocationes done by init_sw_vars.

Fixes: cefe3dfdb9f5 ("rtl8192cu: Call ieee80211_register_hw from rtl_usb_probe")
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
---
 drivers/net/wireless/realtek/rtlwifi/usb.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Ping-Ke Shih Nov. 8, 2024, 2:14 a.m. UTC | #1
Thadeu Lima de Souza Cascardo <cascardo@igalia.com> wrote:
> If ieee80211_register_hw fails, the memory allocated for the firmware will
> not be released. Call deinit_sw_vars as the function that undoes the
> allocationes done by init_sw_vars.
> 
> Fixes: cefe3dfdb9f5 ("rtl8192cu: Call ieee80211_register_hw from rtl_usb_probe")
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
> ---
>  drivers/net/wireless/realtek/rtlwifi/usb.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c b/drivers/net/wireless/realtek/rtlwifi/usb.c
> index c27b116ccdff..8ec687fab572 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/usb.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/usb.c
> @@ -1037,6 +1037,7 @@ int rtl_usb_probe(struct usb_interface *intf,
> 
>  error_init_vars:
>         wait_for_completion(&rtlpriv->firmware_loading_complete);
> +       rtlpriv->cfg->ops->deinit_sw_vars(hw);

Ah. You did this in this patch. Seemingly we can combine these two small
patches. 

>  error_out:
>         rtl_deinit_core(hw);
>  error_out2:
> --
> 2.34.1
diff mbox series

Patch

diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c b/drivers/net/wireless/realtek/rtlwifi/usb.c
index c27b116ccdff..8ec687fab572 100644
--- a/drivers/net/wireless/realtek/rtlwifi/usb.c
+++ b/drivers/net/wireless/realtek/rtlwifi/usb.c
@@ -1037,6 +1037,7 @@  int rtl_usb_probe(struct usb_interface *intf,
 
 error_init_vars:
 	wait_for_completion(&rtlpriv->firmware_loading_complete);
+	rtlpriv->cfg->ops->deinit_sw_vars(hw);
 error_out:
 	rtl_deinit_core(hw);
 error_out2: