Skip to content

Commit c701574

Browse files
michaello316nbd168
authored andcommitted
wifi: mt76: mt7925: fix invalid array index in ssid assignment during hw scan
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: [email protected] Fixes: c948b5d ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips") Signed-off-by: Michael Lo <[email protected]> Signed-off-by: Ming Yen Hsieh <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Felix Fietkau <[email protected]>
1 parent d20de55 commit c701574

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

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

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

1743-
req->ssids[i].ssid_len = cpu_to_le32(sreq->ssids[i].ssid_len);
1744-
memcpy(req->ssids[i].ssid, sreq->ssids[i].ssid,
1743+
req->ssids[n_ssids].ssid_len = cpu_to_le32(sreq->ssids[i].ssid_len);
1744+
memcpy(req->ssids[n_ssids].ssid, sreq->ssids[i].ssid,
17451745
sreq->ssids[i].ssid_len);
17461746
n_ssids++;
17471747
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2869,8 +2869,8 @@ int mt7925_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif,
28692869
if (i > MT7925_RNR_SCAN_MAX_BSSIDS)
28702870
break;
28712871

2872-
ssid->ssids[i].ssid_len = cpu_to_le32(sreq->ssids[i].ssid_len);
2873-
memcpy(ssid->ssids[i].ssid, sreq->ssids[i].ssid,
2872+
ssid->ssids[n_ssids].ssid_len = cpu_to_le32(sreq->ssids[i].ssid_len);
2873+
memcpy(ssid->ssids[n_ssids].ssid, sreq->ssids[i].ssid,
28742874
sreq->ssids[i].ssid_len);
28752875
n_ssids++;
28762876
}

0 commit comments

Comments
 (0)