Commit f2764f61 authored by Souptick Joarder's avatar Souptick Joarder Committed by Kalle Valo

rtlwifi: Fix memory leak when firmware request fails

This patch will fix memory leak when firmware request fails
Signed-off-by: default avatarSouptick Joarder <jrdr.linux@gmail.com>
Acked-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 4de95fc5
...@@ -175,6 +175,8 @@ int rtl88e_init_sw_vars(struct ieee80211_hw *hw) ...@@ -175,6 +175,8 @@ int rtl88e_init_sw_vars(struct ieee80211_hw *hw)
rtl_fw_cb); rtl_fw_cb);
if (err) { if (err) {
pr_info("Failed to request firmware!\n"); pr_info("Failed to request firmware!\n");
vfree(rtlpriv->rtlhal.pfirmware);
rtlpriv->rtlhal.pfirmware = NULL;
return 1; return 1;
} }
......
...@@ -176,6 +176,8 @@ int rtl92c_init_sw_vars(struct ieee80211_hw *hw) ...@@ -176,6 +176,8 @@ int rtl92c_init_sw_vars(struct ieee80211_hw *hw)
rtl_fw_cb); rtl_fw_cb);
if (err) { if (err) {
pr_err("Failed to request firmware!\n"); pr_err("Failed to request firmware!\n");
vfree(rtlpriv->rtlhal.pfirmware);
rtlpriv->rtlhal.pfirmware = NULL;
return 1; return 1;
} }
......
...@@ -85,6 +85,10 @@ static int rtl92cu_init_sw_vars(struct ieee80211_hw *hw) ...@@ -85,6 +85,10 @@ static int rtl92cu_init_sw_vars(struct ieee80211_hw *hw)
err = request_firmware_nowait(THIS_MODULE, 1, err = request_firmware_nowait(THIS_MODULE, 1,
fw_name, rtlpriv->io.dev, fw_name, rtlpriv->io.dev,
GFP_KERNEL, hw, rtl_fw_cb); GFP_KERNEL, hw, rtl_fw_cb);
if (err) {
vfree(rtlpriv->rtlhal.pfirmware);
rtlpriv->rtlhal.pfirmware = NULL;
}
return err; return err;
} }
......
...@@ -183,6 +183,8 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw) ...@@ -183,6 +183,8 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw)
rtl_fw_cb); rtl_fw_cb);
if (err) { if (err) {
pr_err("Failed to request firmware!\n"); pr_err("Failed to request firmware!\n");
vfree(rtlpriv->rtlhal.pfirmware);
rtlpriv->rtlhal.pfirmware = NULL;
return 1; return 1;
} }
......
...@@ -177,6 +177,8 @@ int rtl92ee_init_sw_vars(struct ieee80211_hw *hw) ...@@ -177,6 +177,8 @@ int rtl92ee_init_sw_vars(struct ieee80211_hw *hw)
rtl_fw_cb); rtl_fw_cb);
if (err) { if (err) {
pr_err("Failed to request firmware!\n"); pr_err("Failed to request firmware!\n");
vfree(rtlpriv->rtlhal.pfirmware);
rtlpriv->rtlhal.pfirmware = NULL;
return 1; return 1;
} }
......
...@@ -216,6 +216,8 @@ static int rtl92s_init_sw_vars(struct ieee80211_hw *hw) ...@@ -216,6 +216,8 @@ static int rtl92s_init_sw_vars(struct ieee80211_hw *hw)
rtl92se_fw_cb); rtl92se_fw_cb);
if (err) { if (err) {
pr_err("Failed to request firmware!\n"); pr_err("Failed to request firmware!\n");
vfree(rtlpriv->rtlhal.pfirmware);
rtlpriv->rtlhal.pfirmware = NULL;
return 1; return 1;
} }
......
...@@ -184,6 +184,8 @@ int rtl8723e_init_sw_vars(struct ieee80211_hw *hw) ...@@ -184,6 +184,8 @@ int rtl8723e_init_sw_vars(struct ieee80211_hw *hw)
rtl_fw_cb); rtl_fw_cb);
if (err) { if (err) {
pr_err("Failed to request firmware!\n"); pr_err("Failed to request firmware!\n");
vfree(rtlpriv->rtlhal.pfirmware);
rtlpriv->rtlhal.pfirmware = NULL;
return 1; return 1;
} }
return 0; return 0;
......
...@@ -195,6 +195,8 @@ int rtl8723be_init_sw_vars(struct ieee80211_hw *hw) ...@@ -195,6 +195,8 @@ int rtl8723be_init_sw_vars(struct ieee80211_hw *hw)
rtl_fw_cb); rtl_fw_cb);
if (err) { if (err) {
pr_err("Failed to request firmware!\n"); pr_err("Failed to request firmware!\n");
vfree(rtlpriv->rtlhal.pfirmware);
rtlpriv->rtlhal.pfirmware = NULL;
return 1; return 1;
} }
} }
......
...@@ -196,6 +196,8 @@ int rtl8821ae_init_sw_vars(struct ieee80211_hw *hw) ...@@ -196,6 +196,8 @@ int rtl8821ae_init_sw_vars(struct ieee80211_hw *hw)
rtlpriv->rtlhal.wowlan_firmware = vzalloc(0x8000); rtlpriv->rtlhal.wowlan_firmware = vzalloc(0x8000);
if (!rtlpriv->rtlhal.wowlan_firmware) { if (!rtlpriv->rtlhal.wowlan_firmware) {
pr_err("Can't alloc buffer for wowlan fw.\n"); pr_err("Can't alloc buffer for wowlan fw.\n");
vfree(rtlpriv->rtlhal.pfirmware);
rtlpriv->rtlhal.pfirmware = NULL;
return 1; return 1;
} }
...@@ -222,6 +224,8 @@ int rtl8821ae_init_sw_vars(struct ieee80211_hw *hw) ...@@ -222,6 +224,8 @@ int rtl8821ae_init_sw_vars(struct ieee80211_hw *hw)
rtl_fw_cb); rtl_fw_cb);
if (err) { if (err) {
pr_err("Failed to request normal firmware!\n"); pr_err("Failed to request normal firmware!\n");
vfree(rtlpriv->rtlhal.wowlan_firmware);
vfree(rtlpriv->rtlhal.pfirmware);
return 1; return 1;
} }
} }
...@@ -233,6 +237,8 @@ int rtl8821ae_init_sw_vars(struct ieee80211_hw *hw) ...@@ -233,6 +237,8 @@ int rtl8821ae_init_sw_vars(struct ieee80211_hw *hw)
rtl_wowlan_fw_cb); rtl_wowlan_fw_cb);
if (err) { if (err) {
pr_err("Failed to request wowlan firmware!\n"); pr_err("Failed to request wowlan firmware!\n");
vfree(rtlpriv->rtlhal.wowlan_firmware);
vfree(rtlpriv->rtlhal.pfirmware);
return 1; return 1;
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment