[PATCH] nfc: pn544: i2c: Replace strcpy() with strscpy()

From: tomasz . unger

Date: Tue Feb 24 2026 - 02:53:57 EST


From: Tomasz Unger <tomasz.unger@xxxxxxxx>

strcpy() does not limit the number of bytes copied which can lead to
buffer overflow. Replace with strscpy() which is safer as it limits
the copy to the size of the destination buffer.

Compilation testing:
- checkpatch.pl: 0 errors, 0 warnings
- make drivers/nfc/pn544/i2c.o: compiled successfully

Signed-off-by: Tomasz Unger <tomasz.unger@xxxxxxxx>
---
drivers/nfc/pn544/i2c.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nfc/pn544/i2c.c b/drivers/nfc/pn544/i2c.c
index a0dfb3f98d5a..7261e12aa6b5 100644
--- a/drivers/nfc/pn544/i2c.c
+++ b/drivers/nfc/pn544/i2c.c
@@ -526,7 +526,7 @@ static int pn544_hci_i2c_fw_download(void *phy_id, const char *firmware_name,

pr_info("Starting Firmware Download (%s)\n", firmware_name);

- strcpy(phy->firmware_name, firmware_name);
+ strscpy(phy->firmware_name, firmware_name, sizeof(phy->firmware_name));

phy->hw_variant = hw_variant;
phy->fw_work_state = FW_WORK_STATE_START;
--
2.53.0