Skip to contentSkip to conversation

wifi: mt76: connac: Replace memcpy + hard-coded size with strscpy

PATCH RESEND New Thorsten Blum 1 participant 1 message Oct 17, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 wifi: mt76: connac: Replace memcpy + hard-coded size with strscpy

Use strscpy() to copy the string into the fixed-size buffer 'req.data' instead of hardcoding the number of bytes to copy. This improves maintainability and ensures the buffer is always NUL-terminated.

No functional changes.

---
 drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +2 -1
index fc3e6728fcfb..8fc3ecfc27a0 100644
@@ -2,6 +2,7 @@
 /* Copyright (C) 2020 MediaTek Inc. */
 
 #include <linux/firmware.h>
+#include <linux/string.h>
 #include "mt76_connac2_mac.h"
 #include "mt76_connac_mcu.h"
 
@@ -1974,7 +1975,7 @@ int mt76_connac_mcu_chip_config(struct mt76_dev *dev)
 		.resp_type = 0,
 	};
 
-	memcpy(req.data, "assert", 7);
+	strscpy(req.data, "assert");
 
 	return mt76_mcu_send_msg(dev, MCU_CE_CMD(CHIP_CONFIG),
 				 &req, sizeof(req), false);
Signature · 1 line
2.51.0