Skip to contentSkip to conversation

wifi: mt76: init chan pointer to aovid unexpected behavior

PATCH New Anthony Liu 1 participant 2 messages Dec 2

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 wifi: mt76: init chan pointer to aovid unexpected behavior

In mt76_remain_on_channel(), defensively initialize chandef.chan with the requested channel instead of using an empty initializer.

---
 drivers/net/wireless/mediatek/mt76/channel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/channel.c +1 -1
index b3c17f76b101..0db1e5456c30 100644
@@ -449,7 +449,7 @@ int mt76_remain_on_channel(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 			   struct ieee80211_channel *chan, int duration,
 			   enum ieee80211_roc_type type)
 {
-	struct cfg80211_chan_def chandef = {};
+	struct cfg80211_chan_def chandef = { .chan = chan };
 	struct mt76_phy *phy = hw->priv;
 	struct mt76_dev *dev = phy->dev;
 	struct mt76_vif_link *mlink;
Signature · 1 line
2.45.2
#1 lore raw

PATCH 2/2 wifi: mt76: add boundary check to array accesses

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

---
 drivers/net/wireless/mediatek/mt76/mt76.h            | 6 ++++++
 drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c | 7 +++++++
 2 files changed, 13 insertions(+)
drivers/net/wireless/mediatek/mt76/mt76.h +6 -0
index 237057caf35e..f9c38a8c0722 100644
@@ -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);
drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c +7 -0
index d8268ec56f98..459d5c86c095 100644
@@ -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;
 
Signature · 1 line
2.45.2