All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luca Coelho <luca@coelho.fi>
To: kvalo@codeaurora.org
Cc: linux-wireless@vger.kernel.org
Subject: [PATCH v2 10/12] iwlwifi: pcie: NULLify pointers after free
Date: Wed, 10 Feb 2021 13:56:35 +0200	[thread overview]
Message-ID: <iwlwifi.20210210135352.996b400d2f1c.I630379c504644700322f57b259383ae0af8d1975@changeid> (raw)
In-Reply-To: <20210210115637.276676-1-luca@coelho.fi>

From: Emmanuel Grumbach <emmanuel.grumbach@intel.com>

Remember that those pointers have been freed by setting them
to NULL. Otherwise, we'd keep rxq pointing to random memory
which would prevent us from trying to re-allocate the Rx
resources if we call rx_alloc again.

Also, propagate the allocation failure to the caller of
iwl_pcie_nic_init so that we won't go further in the
start flow.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/pcie/rx.c    | 3 +++
 drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 8 ++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
index 407809c7e958..664481ca58c9 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
@@ -834,8 +834,11 @@ static int iwl_pcie_rx_alloc(struct iwl_trans *trans)
 		trans_pcie->base_rb_stts_dma = 0;
 	}
 	kfree(trans_pcie->rx_pool);
+	trans_pcie->rx_pool = NULL;
 	kfree(trans_pcie->global_table);
+	trans_pcie->global_table = NULL;
 	kfree(trans_pcie->rxq);
+	trans_pcie->rxq = NULL;
 
 	return ret;
 }
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
index a73f2c54d446..c0d2221a18a9 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
@@ -523,11 +523,15 @@ static int iwl_pcie_nic_init(struct iwl_trans *trans)
 	iwl_op_mode_nic_config(trans->op_mode);
 
 	/* Allocate the RX queue, or reset if it is already allocated */
-	iwl_pcie_rx_init(trans);
+	ret = iwl_pcie_rx_init(trans);
+	if (ret)
+		return ret;
 
 	/* Allocate or reset and init all Tx and Command queues */
-	if (iwl_pcie_tx_init(trans))
+	if (iwl_pcie_tx_init(trans)) {
+		iwl_pcie_rx_free(trans);
 		return -ENOMEM;
+	}
 
 	if (trans->trans_cfg->base_params->shadow_reg_enable) {
 		/* enable shadow regs in HW */
-- 
2.30.0


  parent reply	other threads:[~2021-02-10 12:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-10 11:56 [PATCH v2 00/12] iwlwifi: updates intended for v5.12 2021-02-07 Luca Coelho
2021-02-10 11:56 ` [PATCH v2 01/12] iwlwifi: pcie: add a few missing entries for So with Hr Luca Coelho
2021-02-10 12:38   ` Luca Coelho
2021-02-10 11:56 ` [PATCH v2 02/12] iwlwifi: pcie: don't disable interrupts for reg_lock Luca Coelho
2021-02-10 11:56 ` [PATCH v2 03/12] iwlwifi: acpi: fix PPAG table sizes Luca Coelho
2021-02-10 11:56 ` [PATCH v2 04/12] iwlwifi: mvm: fix the type we use in the PPAG table validity checks Luca Coelho
2021-02-10 11:56 ` [PATCH v2 05/12] iwlwifi: mvm: store PPAG enabled/disabled flag properly Luca Coelho
2021-09-07 11:30   ` Kai-Heng Feng
2021-09-07 12:07     ` Luca Coelho
2021-02-10 11:56 ` [PATCH v2 06/12] iwlwifi: mvm: send stored PPAG command instead of local Luca Coelho
2021-02-10 11:56 ` [PATCH v2 07/12] iwlwifi: mvm: enhance a print in CSA flows Luca Coelho
2021-02-10 11:56 ` [PATCH v2 08/12] iwlwifi: mvm: remove useless iwl_mvm_resume_d3() function Luca Coelho
2021-02-10 11:56 ` [PATCH v2 09/12] iwlwifi: mvm: assign SAR table revision to the command later Luca Coelho
2021-02-10 11:56 ` Luca Coelho [this message]
2021-02-10 11:56 ` [PATCH v2 11/12] iwlwifi: when HW has rate offload don't look at control field Luca Coelho
2021-02-10 11:56 ` [PATCH v2 12/12] iwlwifi: pcie: Change Ma device ID 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.20210210135352.996b400d2f1c.I630379c504644700322f57b259383ae0af8d1975@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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.