| From 1554fd0a30b79fa9c170afcbffd504bd3fa11c11 Mon Sep 17 00:00:00 2001 |
| From: Sasha Levin <sashal@kernel.org> |
| Date: Fri, 15 Jan 2021 13:05:49 +0200 |
| Subject: iwlwifi: pcie: avoid potential PNVM leaks |
| |
| From: Johannes Berg <johannes.berg@intel.com> |
| |
| [ Upstream commit 34b9434cd0d425330a0467e767f8d047ef62964d ] |
| |
| If we erroneously try to set the PNVM data again after it has |
| already been set, we could leak the old DMA memory. Avoid that |
| and warn, we shouldn't be doing this. |
| |
| Signed-off-by: Johannes Berg <johannes.berg@intel.com> |
| Fixes: 6972592850c0 ("iwlwifi: read and parse PNVM file") |
| Signed-off-by: Luca Coelho <luciano.coelho@intel.com> |
| Signed-off-by: Kalle Valo <kvalo@codeaurora.org> |
| Link: https://lore.kernel.org/r/iwlwifi.20210115130252.929c2d680429.I086b9490e6c005f3bcaa881b617e9f61908160f3@changeid |
| Signed-off-by: Sasha Levin <sashal@kernel.org> |
| --- |
| drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c | 3 +++ |
| 1 file changed, 3 insertions(+) |
| |
| 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 5512e3c630c31..eeb87cf5ee857 100644 |
| --- a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c |
| +++ b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c |
| @@ -341,6 +341,9 @@ int iwl_trans_pcie_ctx_info_gen3_set_pnvm(struct iwl_trans *trans, |
| return ret; |
| } |
| |
| + if (WARN_ON(prph_sc_ctrl->pnvm_cfg.pnvm_size)) |
| + return -EBUSY; |
| + |
| prph_sc_ctrl->pnvm_cfg.pnvm_base_addr = |
| cpu_to_le64(trans_pcie->pnvm_dram.physical); |
| prph_sc_ctrl->pnvm_cfg.pnvm_size = |
| -- |
| 2.27.0 |
| |