wifi: mt76: mt7925: fix invalid array index in ssid assignment during hw scan
authorMichael Lo <michael.lo@mediatek.com>
Thu, 12 Jun 2025 06:20:46 +0000 (14:20 +0800)
committerFelix Fietkau <nbd@nbd.name>
Mon, 7 Jul 2025 15:42:20 +0000 (17:42 +0200)
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: c948b5da6bbe ("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>
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c

index fa08e952dffa9d6e623a1f6819f136be3a5a0c76..16db0f2082d1ec196872520d8e0d306e2f94a9f5 100644 (file)
@@ -1740,8 +1740,8 @@ int mt76_connac_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif,
                if (!sreq->ssids[i].ssid_len)
                        continue;
 
-               req->ssids[i].ssid_len = cpu_to_le32(sreq->ssids[i].ssid_len);
-               memcpy(req->ssids[i].ssid, sreq->ssids[i].ssid,
+               req->ssids[n_ssids].ssid_len = cpu_to_le32(sreq->ssids[i].ssid_len);
+               memcpy(req->ssids[n_ssids].ssid, sreq->ssids[i].ssid,
                       sreq->ssids[i].ssid_len);
                n_ssids++;
        }
index b8542be0d94565b51ac3575b5e0dff9d2650f167..0ba33409924a9dc5d79c493ec3d51e72c1ca2604 100644 (file)
@@ -2869,8 +2869,8 @@ int mt7925_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif,
                if (i > MT7925_RNR_SCAN_MAX_BSSIDS)
                        break;
 
-               ssid->ssids[i].ssid_len = cpu_to_le32(sreq->ssids[i].ssid_len);
-               memcpy(ssid->ssids[i].ssid, sreq->ssids[i].ssid,
+               ssid->ssids[n_ssids].ssid_len = cpu_to_le32(sreq->ssids[i].ssid_len);
+               memcpy(ssid->ssids[n_ssids].ssid, sreq->ssids[i].ssid,
                       sreq->ssids[i].ssid_len);
                n_ssids++;
        }