mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] wifi: mt76: Fix strscpy usage in mt76_connac2_load_patch
@ 2025-12-27 12:25 Ivan Orlov
  0 siblings, 0 replies; only message in thread
From: Ivan Orlov @ 2025-12-27 12:25 UTC (permalink / raw)
  To: nbd, lorenzo, ryder.lee
  Cc: Ivan Orlov, shayne.chen, sean.wang, linux-wireless, linux-kernel,
	linux-mediatek

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.

Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
---
 drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
index ea99167765b0..01362b097a40 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
@@ -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);
-- 
2.43.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-12-27 12:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-27 12:25 [PATCH] wifi: mt76: Fix strscpy usage in mt76_connac2_load_patch Ivan Orlov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®