Skip to content

Commit febab6b

Browse files
jmberg-intelgregkh
authored andcommitted
iwlwifi: fix leaks/bad data after failed firmware load
[ Upstream commit ab07506 ] If firmware load fails after having loaded some parts of the firmware, e.g. the IML image, then this would leak. For the host command list we'd end up running into a WARN on the next attempt to load another firmware image. Fix this by calling iwl_dealloc_ucode() on failures, and make that also clear the data so we start fresh on the next round. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Luca Coelho <luciano.coelho@intel.com> Link: https://lore.kernel.org/r/iwlwifi.20211210110539.1f742f0eb58a.I1315f22f6aa632d94ae2069f85e1bca5e734dce0@changeid Signed-off-by: Luca Coelho <luciano.coelho@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 81d2e96 commit febab6b

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎drivers/net/wireless/intel/iwlwifi/iwl-drv.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ static void iwl_dealloc_ucode(struct iwl_drv *drv)
185185

186186
for (i = 0; i < IWL_UCODE_TYPE_MAX; i++)
187187
iwl_free_fw_img(drv, drv->fw.img + i);
188+
189+
/* clear the data for the aborted load case */
190+
memset(&drv->fw, 0, sizeof(drv->fw));
188191
}
189192

190193
static int iwl_alloc_fw_desc(struct iwl_drv *drv, struct fw_desc *desc,
@@ -1365,6 +1368,7 @@ static void iwl_req_fw_callback(const struct firmware *ucode_raw, void *context)
13651368
int i;
13661369
bool load_module = false;
13671370
bool usniffer_images = false;
1371+
bool failure = true;
13681372

13691373
fw->ucode_capa.max_probe_length = IWL_DEFAULT_MAX_PROBE_LENGTH;
13701374
fw->ucode_capa.standard_phy_calibration_size =
@@ -1634,6 +1638,7 @@ static void iwl_req_fw_callback(const struct firmware *ucode_raw, void *context)
16341638
op->name, err);
16351639
#endif
16361640
}
1641+
failure = false;
16371642
goto free;
16381643

16391644
try_again:
@@ -1649,6 +1654,9 @@ static void iwl_req_fw_callback(const struct firmware *ucode_raw, void *context)
16491654
complete(&drv->request_firmware_complete);
16501655
device_release_driver(drv->trans->dev);
16511656
free:
1657+
if (failure)
1658+
iwl_dealloc_ucode(drv);
1659+
16521660
if (pieces) {
16531661
for (i = 0; i < ARRAY_SIZE(pieces->img); i++)
16541662
kfree(pieces->img[i].sec);

0 commit comments

Comments
 (0)