Linux wireless drivers development
 help / color / mirror / Atom feed
From: Luca Coelho <luca@coelho.fi>
To: kvalo@codeaurora.org
Cc: linux-wireless@vger.kernel.org,
	Shahar S Matityahu <shahar.s.matityahu@intel.com>,
	Luca Coelho <luciano.coelho@intel.com>
Subject: [PATCH 8/8] iwlwifi: dbg_ini: check for valid region type during regions parsing
Date: Tue, 23 Apr 2019 11:50:14 +0300	[thread overview]
Message-ID: <20190423085014.15390-9-luca@coelho.fi> (raw)
In-Reply-To: <20190423085014.15390-1-luca@coelho.fi>

From: Shahar S Matityahu <shahar.s.matityahu@intel.com>

Add region type checking during regions parsing to avoid attempts to
parse unsupported or illegal region types.

Signed-off-by: Shahar S Matityahu <shahar.s.matityahu@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/fw/dbg.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
index 62fd346ccb77..5f52e40a2903 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
@@ -2469,15 +2469,20 @@ static void iwl_fw_dbg_update_regions(struct iwl_fw_runtime *fwrt,
 {
 	void *iter = (void *)tlv->region_config;
 	int i, size = le32_to_cpu(tlv->num_regions);
+	const char *err_st =
+		"WRT: ext=%d. Invalid region %s %d for apply point %d\n";
 
 	for (i = 0; i < size; i++) {
 		struct iwl_fw_ini_region_cfg *reg = iter, **active;
 		int id = le32_to_cpu(reg->region_id);
 		u32 type = le32_to_cpu(reg->region_type);
 
-		if (WARN(id >= ARRAY_SIZE(fwrt->dump.active_regs),
-			 "WRT: ext=%d. Invalid region id %d for apply point %d\n",
-			 ext, id, pnt))
+		if (WARN(id >= ARRAY_SIZE(fwrt->dump.active_regs), err_st, ext,
+			 "id", id, pnt))
+			break;
+
+		if (WARN(type == 0 || type >= IWL_FW_INI_REGION_NUM, err_st,
+			 ext, "type", type, pnt))
 			break;
 
 		active = &fwrt->dump.active_regs[id];
-- 
2.20.1


  parent reply	other threads:[~2019-04-23  8:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-23  8:50 [PATCH 0/8] iwlwifi: updates intended for v5.2 2019-04-23 Luca Coelho
2019-04-23  8:50 ` [PATCH 1/8] iwlwifi: mvm: Don't sleep in RX path Luca Coelho
2019-04-23  8:50 ` [PATCH 2/8] iwlwifi: pcie: remove stray character in iwl_pcie_rx_alloc_page() Luca Coelho
2019-04-23  8:50 ` [PATCH 3/8] iwlwifi: parse command version TLV Luca Coelho
2019-04-23  8:50 ` [PATCH 4/8] iwlwifi: dbg_ini: add lmac and umac error tables dumping support Luca Coelho
2019-04-23  8:50 ` [PATCH 5/8] iwlwifi: dbg_ini: add periodic trigger support Luca Coelho
2019-04-23  8:50 ` [PATCH 6/8] iwlwifi: dbg: replace dump info device family with HW type Luca Coelho
2019-04-23  8:50 ` [PATCH 7/8] iwlwifi: avoid allocating memory for region with disabled domain Luca Coelho
2019-04-23  8:50 ` Luca Coelho [this message]
2019-04-23  8:53 ` [PATCH 0/8] iwlwifi: updates intended for v5.2 2019-04-23 Luciano 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=20190423085014.15390-9-luca@coelho.fi \
    --to=luca@coelho.fi \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=luciano.coelho@intel.com \
    --cc=shahar.s.matityahu@intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox