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 07/12] iwlwifi: acpi: don't return valid pointer as an ERR_PTR
Date: Wed, 10 Feb 2021 14:29:22 +0200	[thread overview]
Message-ID: <iwlwifi.20210210142629.1c8c4b58c932.I147373f6fd364606b0282af8d402c722eb917225@changeid> (raw)
In-Reply-To: <20210210122927.315774-1-luca@coelho.fi>

From: Haim Dreyfuss <haim.dreyfuss@intel.com>

iwl_acpi_get_wifi_pkg() may return a valid pointer (meaning success),
while `tbl_rev` is invalid (equel to 1).
In this case, we will treat that as an error.
Subsequent "users" of this "error code" may either check for nonzero
(good; pointers are never zero) or negative
(bad; pointers may be "positive") fix that by splitting the if statement.
First check if IS_ERR(wifi_pkg) and then if tbl_rev != 0.

Signed-off-by: Haim Dreyfuss <haim.dreyfuss@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/fw/acpi.c | 22 +++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/acpi.c b/drivers/net/wireless/intel/iwlwifi/fw/acpi.c
index d8b7776a8dde..6aa0dbfa3b6c 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/acpi.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/acpi.c
@@ -478,11 +478,16 @@ int iwl_sar_get_wrds_table(struct iwl_fw_runtime *fwrt)
 
 	wifi_pkg = iwl_acpi_get_wifi_pkg(fwrt->dev, data,
 					 ACPI_WRDS_WIFI_DATA_SIZE, &tbl_rev);
-	if (IS_ERR(wifi_pkg) || tbl_rev != 0) {
+	if (IS_ERR(wifi_pkg)) {
 		ret = PTR_ERR(wifi_pkg);
 		goto out_free;
 	}
 
+	if (tbl_rev != 0) {
+		ret = -EINVAL;
+		goto out_free;
+	}
+
 	if (wifi_pkg->package.elements[1].type != ACPI_TYPE_INTEGER) {
 		ret = -EINVAL;
 		goto out_free;
@@ -516,11 +521,16 @@ int iwl_sar_get_ewrd_table(struct iwl_fw_runtime *fwrt)
 
 	wifi_pkg = iwl_acpi_get_wifi_pkg(fwrt->dev, data,
 					 ACPI_EWRD_WIFI_DATA_SIZE, &tbl_rev);
-	if (IS_ERR(wifi_pkg) || tbl_rev != 0) {
+	if (IS_ERR(wifi_pkg)) {
 		ret = PTR_ERR(wifi_pkg);
 		goto out_free;
 	}
 
+	if (tbl_rev != 0) {
+		ret = -EINVAL;
+		goto out_free;
+	}
+
 	if (wifi_pkg->package.elements[1].type != ACPI_TYPE_INTEGER ||
 	    wifi_pkg->package.elements[2].type != ACPI_TYPE_INTEGER) {
 		ret = -EINVAL;
@@ -576,11 +586,17 @@ int iwl_sar_get_wgds_table(struct iwl_fw_runtime *fwrt)
 
 	wifi_pkg = iwl_acpi_get_wifi_pkg(fwrt->dev, data,
 					 ACPI_WGDS_WIFI_DATA_SIZE, &tbl_rev);
-	if (IS_ERR(wifi_pkg) || tbl_rev > 1) {
+
+	if (IS_ERR(wifi_pkg)) {
 		ret = PTR_ERR(wifi_pkg);
 		goto out_free;
 	}
 
+	if (tbl_rev > 1) {
+		ret = -EINVAL;
+		goto out_free;
+	}
+
 	fwrt->geo_rev = tbl_rev;
 	for (i = 0; i < ACPI_NUM_GEO_PROFILES; i++) {
 		for (j = 0; j < ACPI_GEO_TABLE_SIZE; j++) {
-- 
2.30.0


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

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-10 12:29 [PATCH v2 00/12] iwlwifi: updates intended for v5.12 2021-02-07 part 2 Luca Coelho
2021-02-10 12:29 ` [PATCH v2 01/12] iwlwifi: dbg: remove unsupported regions Luca Coelho
2021-02-10 12:40   ` Luca Coelho
2021-02-10 12:29 ` [PATCH v2 02/12] iwlwifi: api: clean up some documentation/bits Luca Coelho
2021-02-10 12:29 ` [PATCH v2 03/12] iwlwifi: dbg: add op_mode callback for collecting debug data Luca Coelho
2021-02-10 12:29 ` [PATCH v2 04/12] iwlwifi: declare support for triggered SU/MU beamforming feedback Luca Coelho
2021-02-10 12:29 ` [PATCH v2 05/12] iwlwifi: remove flags argument for nic_access Luca Coelho
2021-02-10 12:29 ` [PATCH v2 06/12] iwlwifi: queue: add fake tx time point Luca Coelho
2021-02-10 12:29 ` Luca Coelho [this message]
2021-02-10 12:29 ` [PATCH v2 08/12] iwlwifi: pcie: add CDB bit to the device configuration parsing Luca Coelho
2021-02-10 12:29 ` [PATCH v2 09/12] iwlwifi: pcie: add AX201 and AX211 radio modules for Ma devices Luca Coelho
2021-02-10 12:29 ` [PATCH v2 10/12] iwlwifi: correction of group-id once sending REPLY_ERROR Luca Coelho
2021-02-10 12:29 ` [PATCH v2 11/12] iwlwifi: pcie: don't crash when rx queues aren't allocated in interrupt Luca Coelho
2021-02-10 12:29 ` [PATCH v2 12/12] iwlwifi:mvm: Add support for version 2 of the LARI_CONFIG_CHANGE command 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.20210210142629.1c8c4b58c932.I147373f6fd364606b0282af8d402c722eb917225@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.