]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wifi: iwlwifi: mld: avoid memory leak if mcc_init fails
authorMiri Korenblit <miriam.rachel.korenblit@intel.com>
Wed, 23 Apr 2025 06:16:33 +0000 (09:16 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 23 Apr 2025 13:37:38 +0000 (15:37 +0200)
allocating mld->nvm_data used to be the last thing done in
iwl_mld_load_fw, so there was no need to free on any error path of
iwl_mld_load_fw.
But now iwl_mld_load_fw also calls iwl_mld_init_mcc, that can fail,
after allocating nvm->data. In that case, it is not freed.

As allocating the NVM data should only be done at op mode start anyway,
simply move it to there, where it is already freed in the right error
paths.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Link: https://patch.msgid.link/20250423091408.d07469f866ac.I84ad2e624ce7cd4a661c73b4942186e50cdf82b2@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlwifi/mld/fw.c
drivers/net/wireless/intel/iwlwifi/mld/mld.c

index 62da137e102479124f691f19d67955b21c9a4ec3..77cc8e4bb498354b5b3edb2464098ade9b813d57 100644 (file)
@@ -11,7 +11,6 @@
 #include "fw/dbg.h"
 #include "fw/pnvm.h"
 #include "hcmd.h"
-#include "iwl-nvm-parse.h"
 #include "power.h"
 #include "mcc.h"
 #include "led.h"
@@ -308,16 +307,6 @@ static int iwl_mld_run_fw_init_sequence(struct iwl_mld *mld)
                goto init_failure;
        }
 
-       if (!mld->nvm_data) {
-               mld->nvm_data = iwl_get_nvm(mld->trans, mld->fw, 0, 0);
-               if (IS_ERR(mld->nvm_data)) {
-                       ret = PTR_ERR(mld->nvm_data);
-                       mld->nvm_data = NULL;
-                       IWL_ERR(mld, "Failed to read NVM: %d\n", ret);
-                       goto init_failure;
-               }
-       }
-
        return 0;
 
 init_failure:
index 367f9738c011e2e9dbc6db1ed0e9c5c59eaa1978..8d788af8dcc871aa65cefc6c71025c40f9e2dc00 100644 (file)
@@ -26,6 +26,8 @@
 #include "hcmd.h"
 #include "fw/api/location.h"
 
+#include "iwl-nvm-parse.h"
+
 #define DRV_DESCRIPTION "Intel(R) MLD wireless driver for Linux"
 MODULE_DESCRIPTION(DRV_DESCRIPTION);
 MODULE_LICENSE("GPL");
@@ -412,6 +414,14 @@ iwl_op_mode_mld_start(struct iwl_trans *trans, const struct iwl_cfg *cfg,
                        break;
        }
 
+       if (!ret) {
+               mld->nvm_data = iwl_get_nvm(mld->trans, mld->fw, 0, 0);
+               if (IS_ERR(mld->nvm_data)) {
+                       IWL_ERR(mld, "Failed to read NVM: %d\n", ret);
+                       ret = PTR_ERR(mld->nvm_data);
+               }
+       }
+
        if (ret) {
                wiphy_unlock(mld->wiphy);
                rtnl_unlock();