Skip to content

Commit 5b05e1d

Browse files
michaello316opsiff
authored andcommitted
wifi: mt76: mt7925: fix invalid array index in ssid assignment during hw scan
stable inclusion from stable-v6.12.39 category: bugfix commit c701574 upstream. Update the destination index to use 'n_ssids', which is incremented only when a valid SSID is present. Previously, both mt76_connac_mcu_hw_scan() and mt7925_mcu_hw_scan() used the loop index 'i' for the destination array, potentially leaving gaps if any source SSIDs had zero length. Cc: stable@vger.kernel.org Fixes: c948b5d ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips") Signed-off-by: Michael Lo <michael.lo@mediatek.com> Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com> Link: https://patch.msgid.link/20250612062046.160598-1-mingyen.hsieh@mediatek.com Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit a7b2f250ffcd18f3ea31c2b57e757a59e7be9e02) (cherry picked from commit 42d2a1b) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent 5d48c8a commit 5b05e1d

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,8 +1678,8 @@ int mt76_connac_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif,
16781678
if (!sreq->ssids[i].ssid_len)
16791679
continue;
16801680

1681-
req->ssids[i].ssid_len = cpu_to_le32(sreq->ssids[i].ssid_len);
1682-
memcpy(req->ssids[i].ssid, sreq->ssids[i].ssid,
1681+
req->ssids[n_ssids].ssid_len = cpu_to_le32(sreq->ssids[i].ssid_len);
1682+
memcpy(req->ssids[n_ssids].ssid, sreq->ssids[i].ssid,
16831683
sreq->ssids[i].ssid_len);
16841684
n_ssids++;
16851685
}

drivers/net/wireless/mediatek/mt76/mt7925/mcu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,8 +2401,8 @@ int mt7925_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif,
24012401
if (!sreq->ssids[i].ssid_len)
24022402
continue;
24032403

2404-
ssid->ssids[i].ssid_len = cpu_to_le32(sreq->ssids[i].ssid_len);
2405-
memcpy(ssid->ssids[i].ssid, sreq->ssids[i].ssid,
2404+
ssid->ssids[n_ssids].ssid_len = cpu_to_le32(sreq->ssids[i].ssid_len);
2405+
memcpy(ssid->ssids[n_ssids].ssid, sreq->ssids[i].ssid,
24062406
sreq->ssids[i].ssid_len);
24072407
n_ssids++;
24082408
}

0 commit comments

Comments
 (0)