Skip to contentSkip to conversation

wifi: mt76: Fix strscpy usage in mt76_connac2_load_patch

PATCH New Ivan Orlov 1 participant 1 message Dec 27, 2025

Subsystems (2)
lore
Share & tools
lore

Ivan Orlov

author
#0 lore raw

PATCH 1/1 wifi: mt76: Fix strscpy usage in mt76_connac2_load_patch

Since mt76_connac2_patch_hdr->build_date size is 16, copying at most 17 bytes into build_date from it causes a panic when CONFIG_FORTIFY_SOURCE is enabled. So, make it 16 bytes instead to match the corresponding field of mt76_connac2_patch_hdr.

Also, since strscpy always adds a null terminator, remove the line which adds it explicitly at the end of the buffer.

---
 drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +1 -2
index ea99167765b0..01362b097a40 100644
@@ -3101,7 +3101,7 @@ int mt76_connac2_load_patch(struct mt76_dev *dev, const char *fw_name)
 	int i, ret, sem, max_len = mt76_is_sdio(dev) ? 2048 : 4096;
 	const struct mt76_connac2_patch_hdr *hdr;
 	const struct firmware *fw = NULL;
-	char build_date[17];
+	char build_date[16];
 
 	sem = mt76_connac_mcu_patch_sem_ctrl(dev, true);
 	switch (sem) {
@@ -3126,7 +3126,6 @@ int mt76_connac2_load_patch(struct mt76_dev *dev, const char *fw_name)
 
 	hdr = (const void *)fw->data;
 	strscpy(build_date, hdr->build_date, sizeof(build_date));
-	build_date[16] = '\0';
 	strim(build_date);
 	dev_info(dev->dev, "HW/SW Version: 0x%x, Build Time: %.16s\n",
 		 be32_to_cpu(hdr->hw_sw_ver), build_date);
Signature · 1 line
2.43.0