All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miri Korenblit <miriam.rachel.korenblit@intel.com>
To: johannes@sipsolutions.net
Cc: linux-wireless@vger.kernel.org,
	Johannes Berg <johannes.berg@intel.com>,
	Gregory Greenman Gregory <gregory.greenman@intel.com>
Subject: [PATCH 09/14] wifi: iwlwifi: acpi: fix WPFC reading
Date: Sun, 28 Jan 2024 08:53:55 +0200	[thread overview]
Message-ID: <20240128084842.2afeb476b62d.I200568dc42a277e21c12be99d5aaa39b009d45da@changeid> (raw)
In-Reply-To: <20240128065400.2550604-1-miriam.rachel.korenblit@intel.com>

From: Johannes Berg <johannes.berg@intel.com>

The code reading the WPFC table needs to take into account
the domain type (first element in the package), shouldn't
leak the memory if it fails, and has a bad comment. Fix all
these issues.

Fixes: c4c954547755 ("wifi: iwlwifi: implement WPFC ACPI table loading")
Reported-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Reviewed-by: Gregory Greenman Gregory <gregory.greenman@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/fw/acpi.c | 10 +++++-----
 drivers/net/wireless/intel/iwlwifi/fw/acpi.h |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/acpi.c b/drivers/net/wireless/intel/iwlwifi/fw/acpi.c
index b96f30d11644..72a0a9565371 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/acpi.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/acpi.c
@@ -1293,7 +1293,6 @@ void iwl_acpi_get_phy_filters(struct iwl_fw_runtime *fwrt,
 	if (IS_ERR(data))
 		return;
 
-	/* try to read wtas table revision 1 or revision 0*/
 	wifi_pkg = iwl_acpi_get_wifi_pkg(fwrt->dev, data,
 					 ACPI_WPFC_WIFI_DATA_SIZE,
 					 &tbl_rev);
@@ -1303,13 +1302,14 @@ void iwl_acpi_get_phy_filters(struct iwl_fw_runtime *fwrt,
 	if (tbl_rev != 0)
 		goto out_free;
 
-	BUILD_BUG_ON(ARRAY_SIZE(filters->filter_cfg_chains) != ACPI_WPFC_WIFI_DATA_SIZE);
+	BUILD_BUG_ON(ARRAY_SIZE(filters->filter_cfg_chains) !=
+		     ACPI_WPFC_WIFI_DATA_SIZE - 1);
 
 	for (i = 0; i < ARRAY_SIZE(filters->filter_cfg_chains); i++) {
-		if (wifi_pkg->package.elements[i].type != ACPI_TYPE_INTEGER)
-			return;
+		if (wifi_pkg->package.elements[i + 1].type != ACPI_TYPE_INTEGER)
+			goto out_free;
 		tmp.filter_cfg_chains[i] =
-			cpu_to_le32(wifi_pkg->package.elements[i].integer.value);
+			cpu_to_le32(wifi_pkg->package.elements[i + 1].integer.value);
 	}
 
 	IWL_DEBUG_RADIO(fwrt, "Loaded WPFC filter config from ACPI\n");
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/acpi.h b/drivers/net/wireless/intel/iwlwifi/fw/acpi.h
index e9277f6f3582..39106ccb4b9b 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/acpi.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/acpi.h
@@ -56,7 +56,7 @@
 #define ACPI_EWRD_WIFI_DATA_SIZE_REV2	((ACPI_SAR_PROFILE_NUM - 1) * \
 					 ACPI_SAR_NUM_CHAINS_REV2 * \
 					 ACPI_SAR_NUM_SUB_BANDS_REV2 + 3)
-#define ACPI_WPFC_WIFI_DATA_SIZE	4 /* 4 filter config words */
+#define ACPI_WPFC_WIFI_DATA_SIZE	5 /* domain and 4 filter config words */
 
 /* revision 0 and 1 are identical, except for the semantics in the FW */
 #define ACPI_GEO_NUM_BANDS_REV0		2
-- 
2.34.1


  parent reply	other threads:[~2024-01-28  6:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-28  6:53 [PATCH 00/14] wifi: iwlwifi: updates - 2024-01-28 Miri Korenblit
2024-01-28  6:53 ` [PATCH 01/14] wifi: iwlwifi: disable eSR when BT is active Miri Korenblit
2024-01-28  6:53 ` [PATCH 02/14] wifi: iwlwifi: mvm: report beacon protection failures Miri Korenblit
2024-01-28  6:53 ` [PATCH 03/14] wifi: iwlwifi: mvm: d3: disconnect on GTK rekey failure Miri Korenblit
2024-01-28  6:53 ` [PATCH 04/14] wifi: iwlwifi: fix some kernel-doc issues Miri Korenblit
2024-01-28  6:53 ` [PATCH 05/14] wifi: iwlwifi: dbg-tlv: avoid extra allocation/copy Miri Korenblit
2024-01-28  6:53 ` [PATCH 06/14] wifi: iwlwifi: dbg-tlv: use struct_size() for allocation Miri Korenblit
2024-01-28  6:53 ` [PATCH 07/14] wifi: iwlwifi: dbg-tlv: ensure NUL termination Miri Korenblit
2024-01-28  6:53 ` [PATCH 08/14] wifi: iwlwifi: fw: dbg: ensure correct config name sizes Miri Korenblit
2024-01-28  6:53 ` Miri Korenblit [this message]
2024-01-28  6:53 ` [PATCH 10/14] wifi: iwlwifi: mvm: disconnect station vifs if recovery failed Miri Korenblit
2024-01-28  6:53 ` [PATCH 11/14] wifi: iwlwifi: mvm: fix a battery life regression Miri Korenblit
2024-01-28  6:53 ` [PATCH 12/14] wifi: iwlwifi: mvm: initialize rates in FW earlier Miri Korenblit
2024-01-28  6:53 ` [PATCH 13/14] wifi: iwlwifi: implement GLAI ACPI table loading Miri Korenblit
2024-01-28  6:54 ` [PATCH 14/14] wifi: iwlwifi: cleanup uefi variables loading Miri Korenblit

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=20240128084842.2afeb476b62d.I200568dc42a277e21c12be99d5aaa39b009d45da@changeid \
    --to=miriam.rachel.korenblit@intel.com \
    --cc=gregory.greenman@intel.com \
    --cc=johannes.berg@intel.com \
    --cc=johannes@sipsolutions.net \
    --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.