iwlwifi: mvm: fix nvm_data leak
authorLuca Coelho <luciano.coelho@intel.com>
Wed, 3 May 2017 12:12:09 +0000 (15:12 +0300)
committerLuca Coelho <luciano.coelho@intel.com>
Fri, 23 Jun 2017 09:03:13 +0000 (12:03 +0300)
We allocate nvm_data in iwl_mvm_nvm_get_from_fw().  If something goes
wrong after the allocation (i.e. if no valid MAC address is valid), we
should free nvm_data before returning an error.

Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
drivers/net/wireless/intel/iwlwifi/mvm/nvm.c

index ad8bd90deed290afe2c0898fa21c7b9396851fdd..efdcffbaac6f908ab526379823e645c40d331483 100644 (file)
@@ -596,7 +596,7 @@ int iwl_mvm_nvm_get_from_fw(struct iwl_mvm *mvm)
        if (!is_valid_ether_addr(mvm->nvm_data->hw_addr)) {
                IWL_ERR(trans, "no valid mac address was found\n");
                ret = -EINVAL;
-               goto out;
+               goto err_free;
        }
 
        /* Initialize general data */
@@ -628,7 +628,11 @@ int iwl_mvm_nvm_get_from_fw(struct iwl_mvm *mvm)
                        mvm->nvm_data->valid_rx_ant & mvm->fw->valid_rx_ant,
                        rsp->regulatory.lar_enabled && lar_fw_supported);
 
-       ret = 0;
+       iwl_free_resp(&hcmd);
+       return 0;
+
+err_free:
+       kfree(mvm->nvm_data);
 out:
        iwl_free_resp(&hcmd);
        return ret;