Linux wireless drivers development
 help / color / mirror / Atom feed
From: Anthony Liu <anthony.liu@mediatek.com>
To: <anthony.liu@mediatek.com>
Cc: <Emery.Hsin@mediatek.com>, <Jb.Tsai@mediatek.com>,
	<Leon.Yen@mediatek.com>, <Litien.Chang@mediatek.com>,
	<Quan.Zhou@mediatek.com>, <Ryder.Lee@mediatek.com>,
	<Sean.Wang@mediatek.com>, <kun.wu@mediatek.com>,
	<linux-wireless@vger.kernel.org>, <lorenzo@kernel.org>,
	<nbd@nbd.name>
Subject: [PATCH v1 2/2] wifi: mt76: add boundary check to array accesses
Date: Wed, 2 Dec 2026 16:18:06 +0800	[thread overview]
Message-ID: <20261202081806.1297416-2-anthony.liu@mediatek.com> (raw)
In-Reply-To: <20261202081806.1297416-1-anthony.liu@mediatek.com>

Add array boundary check to functions accessing Tx qeueus, MCU
queues, and ACPI data tables.

Signed-off-by: Anthony Liu <anthony.liu@mediatek.com>
---
 drivers/net/wireless/mediatek/mt76/mt76.h            | 6 ++++++
 drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index 237057caf35e..f9c38a8c0722 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -1397,6 +1397,9 @@ static inline int mt76_init_tx_queue(struct mt76_phy *phy, int qid, int idx,
 {
 	struct mt76_queue *q;
 
+	if (qid < 0 || qid >= ARRAY_SIZE(dev->q_tx))
+		return -EINVAL;
+
 	q = mt76_init_queue(phy->dev, qid, idx, n_desc, ring_base, wed, flags);
 	if (IS_ERR(q))
 		return PTR_ERR(q);
@@ -1411,6 +1414,9 @@ static inline int mt76_init_mcu_queue(struct mt76_dev *dev, int qid, int idx,
 {
 	struct mt76_queue *q;
 
+	if (qid < 0 || qid >= ARRAY_SIZE(dev->q_mcu))
+		return -EINVAL;
+
 	q = mt76_init_queue(dev, qid, idx, n_desc, ring_base, NULL, 0);
 	if (IS_ERR(q))
 		return PTR_ERR(q);
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c b/drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c
index d8268ec56f98..459d5c86c095 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c
+++ b/drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c
@@ -432,6 +432,9 @@ mt792x_acpi_get_mtcl_map_v3(int row, int column, struct mt792x_asar_cl_v3 *cl)
 	u32 config = 0;
 	u8 mode_be = 0;
 
+	if (row < 0 || row >= ARRAY_SIZE(cl->clbe))
+		return 0;
+
 	mode_be = (cl->mode_be > 0x02) ? 0 : cl->mode_be;
 
 	if (cl->version > 2 && cl->clbe[row] & BIT(column))
@@ -446,6 +449,10 @@ mt792x_acpi_get_mtcl_map(int row, int column, struct mt792x_asar_cl *cl)
 	u32 config = 0;
 	u8 mode_6g, mode_5g9;
 
+	if (row < 0 || row >= ARRAY_SIZE(cl->cl6g) ||
+	    row >= ARRAY_SIZE(cl->cl5g9))
+		return 0;
+
 	mode_6g = (cl->mode_6g > 0x02) ? 0 : cl->mode_6g;
 	mode_5g9 = (cl->mode_5g9 > 0x01) ? 0 : cl->mode_5g9;
 
-- 
2.45.2


      reply	other threads:[~2026-12-02  8:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  8:18 [PATCH v1 1/2] wifi: mt76: init chan pointer to aovid unexpected behavior Anthony Liu
2026-12-02  8:18 ` Anthony Liu [this message]

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=20261202081806.1297416-2-anthony.liu@mediatek.com \
    --to=anthony.liu@mediatek.com \
    --cc=Emery.Hsin@mediatek.com \
    --cc=Jb.Tsai@mediatek.com \
    --cc=Leon.Yen@mediatek.com \
    --cc=Litien.Chang@mediatek.com \
    --cc=Quan.Zhou@mediatek.com \
    --cc=Ryder.Lee@mediatek.com \
    --cc=Sean.Wang@mediatek.com \
    --cc=kun.wu@mediatek.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=nbd@nbd.name \
    /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