iwlwifi: don't leak memory on allocation failure

If we fail to allocate the small chunk of memory for the
pieces of the firmware file, we leak the whole firmware
image instead...

Since the allocation failure is really unlikely, just bail
out at that point instead.

Remove the error message at the label since we now (and
actually have been) use it for various reasons.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
This commit is contained in:
Johannes Berg 2017-02-28 16:44:16 +01:00 committed by Luca Coelho
parent b0fa818e6c
commit 53d515ec67
1 changed files with 7 additions and 6 deletions

View File

@ -1282,7 +1282,7 @@ static void iwl_req_fw_callback(const struct firmware *ucode_raw, void *context)
pieces = kzalloc(sizeof(*pieces), GFP_KERNEL); pieces = kzalloc(sizeof(*pieces), GFP_KERNEL);
if (!pieces) if (!pieces)
return; goto out_free_fw;
if (!ucode_raw) if (!ucode_raw)
goto try_again; goto try_again;
@ -1512,17 +1512,18 @@ static void iwl_req_fw_callback(const struct firmware *ucode_raw, void *context)
goto free; goto free;
out_free_fw: out_free_fw:
IWL_ERR(drv, "failed to allocate pci memory\n");
iwl_dealloc_ucode(drv); iwl_dealloc_ucode(drv);
release_firmware(ucode_raw); release_firmware(ucode_raw);
out_unbind: out_unbind:
complete(&drv->request_firmware_complete); complete(&drv->request_firmware_complete);
device_release_driver(drv->trans->dev); device_release_driver(drv->trans->dev);
free: free:
for (i = 0; i < ARRAY_SIZE(pieces->img); i++) if (pieces) {
kfree(pieces->img[i].sec); for (i = 0; i < ARRAY_SIZE(pieces->img); i++)
kfree(pieces->dbg_mem_tlv); kfree(pieces->img[i].sec);
kfree(pieces); kfree(pieces->dbg_mem_tlv);
kfree(pieces);
}
} }
struct iwl_drv *iwl_drv_start(struct iwl_trans *trans) struct iwl_drv *iwl_drv_start(struct iwl_trans *trans)