iwlwifi: pcie: fix memory leaks in iwl_pcie_ctxt_info_gen3_init
authorNavid Emamdoost <navid.emamdoost@gmail.com>
Fri, 27 Sep 2019 20:56:04 +0000 (15:56 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Jan 2020 18:46:57 +0000 (19:46 +0100)
commit6e41dd9731e13b0bdf2f57f84b9d25d009bd9f87
tree05fd5485a6d8cf48d6b5706374dc64b71f13bc1a
parent09044a4a142404799e519def0bbfcc98fa68c677
iwlwifi: pcie: fix memory leaks in iwl_pcie_ctxt_info_gen3_init

commit 0f4f199443faca715523b0659aa536251d8b978f upstream.

In iwl_pcie_ctxt_info_gen3_init there are cases that the allocated dma
memory is leaked in case of error.

DMA memories prph_scratch, prph_info, and ctxt_info_gen3 are allocated
and initialized to be later assigned to trans_pcie. But in any error case
before such assignment the allocated memories should be released.

First of such error cases happens when iwl_pcie_init_fw_sec fails.
Current implementation correctly releases prph_scratch. But in two
sunsequent error cases where dma_alloc_coherent may fail, such
releases are missing.

This commit adds release for prph_scratch when allocation for
prph_info fails, and adds releases for prph_scratch and prph_info when
allocation for ctxt_info_gen3 fails.

Fixes: 2ee824026288 ("iwlwifi: pcie: support context information for 22560 devices")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c