wifi: mt76: init chan pointer to aovid unexpected behavior
Subsystems (2)
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.
Signed-off-by Anthony Liu <[email protected]>
--- drivers/net/wireless/mediatek/mt76/channel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/channel.c +1 -1
@@ -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
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.
Signed-off-by Anthony Liu <[email protected]>
--- 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
@@ -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
@@ -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