Skip to contentSkip to conversation

ata: Replace deprecated strcpy with strscpy in it821x_display_disk

PATCH Applied Thorsten Blum 3 participants 3 messages Oct 18, 2025 – Oct 23, 2025 libata

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ata: Replace deprecated strcpy with strscpy in it821x_display_disk

strcpy() is deprecated; use strscpy() instead.

Replace the hard-coded buffer size 8 with sizeof(mbuf) when using snprintf() while we're at it.

---
 drivers/ata/pata_it821x.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/ata/pata_it821x.c +3 -2
index 042f6ad1f7c6..fc762dcc61bf 100644
@@ -75,6 +75,7 @@
 #include <linux/blkdev.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
+#include <linux/string.h>
 #include <scsi/scsi_host.h>
 #include <linux/libata.h>
 
@@ -632,9 +633,9 @@ static void it821x_display_disk(struct ata_port *ap, int n, u8 *buf)
 		cbl = "";
 
 	if (mode)
-		snprintf(mbuf, 8, "%5s%d", mtype, mode - 1);
+		snprintf(mbuf, sizeof(mbuf), "%5s%d", mtype, mode - 1);
 	else
-		strcpy(mbuf, "PIO");
+		strscpy(mbuf, "PIO");
 	if (buf[52] == 4)
 		ata_port_info(ap, "%d: %-6s %-8s          %s %s\n",
 				n, mbuf, types[buf[52]], id, cbl);
Signature · 1 line
2.51.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Thorsten Blum

strcpy() is deprecated; use strscpy() instead.

Replace the hard-coded buffer size 8 with sizeof(mbuf) when using snprintf() while we're at it.

Note: the patch title should be:

ata: pata_it821x: Replace deprecated strcpy with strscpy in it821x_display_disk

Niklas can fix that when applying I think.

Signature · 2 lines
Damien Le Moal
Western Digital Research
maintainer Applied
#2 lore raw
In reply to Thorsten Blum
Quoted 7 lines · Thorsten Blum

strcpy() is deprecated; use strscpy() instead.

Replace the hard-coded buffer size 8 with sizeof(mbuf) when using snprintf() while we're at it.

Applied, thank you!

https://git.kernel.org/pub/scm/linux/kernel/git/libata/linux.git/commit/?h=for-6.19&id=4ea303d9e9862ff8bd3707f67b267646b8ffd3ec