From: Luca Coelho <luca@coelho.fi> To: kvalo@codeaurora.org Cc: linux-wireless@vger.kernel.org Subject: [PATCH for v5.11 10/12] iwlwifi: pcie: fix context info memory leak Date: Fri, 15 Jan 2021 13:05:56 +0200 Message-ID: <iwlwifi.20210115130252.97172cbaa67c.I3473233d0ad01a71aa9400832fb2b9f494d88a11@changeid> (raw) In-Reply-To: <20210115110558.1248847-1-luca@coelho.fi> From: Johannes Berg <johannes.berg@intel.com> If the image loader allocation fails, we leak all the previously allocated memory. Fix this. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Luca Coelho <luciano.coelho@intel.com> --- .../net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c index 342a53e4488c..5b5134dd49af 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c @@ -198,8 +198,10 @@ int iwl_pcie_ctxt_info_gen3_init(struct iwl_trans *trans, /* Allocate IML */ iml_img = dma_alloc_coherent(trans->dev, trans->iml_len, &trans_pcie->iml_dma_addr, GFP_KERNEL); - if (!iml_img) - return -ENOMEM; + if (!iml_img) { + ret = -ENOMEM; + goto err_free_ctxt_info; + } memcpy(iml_img, trans->iml, trans->iml_len); @@ -237,6 +239,11 @@ int iwl_pcie_ctxt_info_gen3_init(struct iwl_trans *trans, return 0; +err_free_ctxt_info: + dma_free_coherent(trans->dev, sizeof(*trans_pcie->ctxt_info_gen3), + trans_pcie->ctxt_info_gen3, + trans_pcie->ctxt_info_dma_addr); + trans_pcie->ctxt_info_gen3 = NULL; err_free_prph_info: dma_free_coherent(trans->dev, sizeof(*prph_info), -- 2.29.2
next prev parent reply index Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-01-15 11:05 [PATCH for v5.11 00/12] iwlwifi: fixes intended for v5.10 2020-12-02 Luca Coelho 2021-01-15 11:05 ` [PATCH for v5.11 01/12] iwlwifi: mvm: skip power command when unbinding vif during CSA Luca Coelho 2021-01-25 13:54 ` Kalle Valo 2021-01-15 11:05 ` [PATCH for v5.11 02/12] iwlwifi: mvm: take mutex for calling iwl_mvm_get_sync_time() Luca Coelho 2021-01-15 11:05 ` [PATCH for v5.11 03/12] iwlwifi: pcie: avoid potential PNVM leaks Luca Coelho 2021-01-15 11:05 ` [PATCH for v5.11 04/12] iwlwifi: pnvm: don't skip everything when not reloading Luca Coelho 2021-01-15 11:05 ` [PATCH for v5.11 05/12] iwlwifi: pnvm: don't try to load after failures Luca Coelho 2021-01-15 11:05 ` [PATCH for v5.11 06/12] iwlwifi: fix the NMI flow for old devices Luca Coelho 2021-01-15 11:05 ` [PATCH for v5.11 07/12] iwlwifi: queue: don't crash if txq->entries is NULL Luca Coelho 2021-01-15 11:05 ` [PATCH for v5.11 08/12] iwlwifi: pcie: set LTR on more devices Luca Coelho 2021-01-15 11:05 ` [PATCH for v5.11 09/12] iwlwifi: pcie: add a NULL check in iwl_pcie_txq_unmap Luca Coelho 2021-01-15 11:05 ` Luca Coelho [this message] 2021-01-15 11:05 ` [PATCH for v5.11 11/12] iwlwifi: pcie: use jiffies for memory read spin time limit Luca Coelho 2021-01-18 15:16 ` Kalle Valo 2021-01-18 15:18 ` Kalle Valo 2021-01-18 15:51 ` Luca Coelho 2021-01-15 11:05 ` [PATCH for v5.11 12/12] iwlwifi: pcie: reschedule in long-running memory reads Luca Coelho
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=iwlwifi.20210115130252.97172cbaa67c.I3473233d0ad01a71aa9400832fb2b9f494d88a11@changeid \ --to=luca@coelho.fi \ --cc=kvalo@codeaurora.org \ --cc=linux-wireless@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Linux-Wireless Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/linux-wireless/0 linux-wireless/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 linux-wireless linux-wireless/ https://lore.kernel.org/linux-wireless \ linux-wireless@vger.kernel.org public-inbox-index linux-wireless Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.kernel.vger.linux-wireless AGPL code for this site: git clone https://public-inbox.org/public-inbox.git