Skip to contentSkip to conversation

sparc: PCI: Replace deprecated strcpy() with strscpy()

PATCH RESEND In review Thorsten Blum 3 participants 4 messages Sep 17, 2025 – Sep 22, 2025 SPARC + UltraSPARC (sparc/sparc64)

v1 of 3 In review Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 sparc: PCI: Replace deprecated strcpy() with strscpy()

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

No functional changes intended.

---
 arch/sparc/kernel/pcic.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
arch/sparc/kernel/pcic.c +4 -3
index 25fe0a061732..f894ae79e78a 100644
@@ -16,6 +16,7 @@
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
+#include <linux/string.h>
 #include <linux/jiffies.h>
 
 #include <asm/swift.h> /* for cache flushing. */
@@ -352,7 +353,7 @@ int __init pcic_probe(void)
 	pbm = &pcic->pbm;
 	pbm->prom_node = node;
 	prom_getstring(node, "name", namebuf, 63);  namebuf[63] = 0;
-	strcpy(pbm->prom_name, namebuf);
+	strscpy(pbm->prom_name, namebuf);
 
 	{
 		extern int pcic_nmi_trap_patch[4];
@@ -477,7 +478,7 @@ static void pcic_map_pci_device(struct linux_pcic *pcic,
 	int j;
 
 	if (node == 0 || node == -1) {
-		strcpy(namebuf, "???");
+		strscpy(namebuf, "???");
 	} else {
 		prom_getstring(node, "name", namebuf, 63); namebuf[63] = 0;
 	}
@@ -536,7 +537,7 @@ pcic_fill_irq(struct linux_pcic *pcic, struct pci_dev *dev, int node)
 	char namebuf[64];
 
 	if (node == 0 || node == -1) {
-		strcpy(namebuf, "???");
+		strscpy(namebuf, "???");
 	} else {
 		prom_getstring(node, "name", namebuf, sizeof(namebuf));
 	}
Signature · 1 line
2.51.0
#1 lore raw
Quoted 6 lines · Thorsten Blum

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

No functional changes intended.

No objection from me, but no particular PCI core issue and I don't maintain this file, so up to the sparc folks if they want it.

I would consider making a single patch to address this issue everywhere in arch/sparc so it can all be reviewed together.

Quoted 46 lines
---
 arch/sparc/kernel/pcic.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
arch/sparc/kernel/pcic.c +4 -3
index 25fe0a061732..f894ae79e78a 100644
@@ -16,6 +16,7 @@
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
+#include <linux/string.h>
 #include <linux/jiffies.h>
 
 #include <asm/swift.h> /* for cache flushing. */
@@ -352,7 +353,7 @@ int __init pcic_probe(void)
 	pbm = &pcic->pbm;
 	pbm->prom_node = node;
 	prom_getstring(node, "name", namebuf, 63);  namebuf[63] = 0;
-	strcpy(pbm->prom_name, namebuf);
+	strscpy(pbm->prom_name, namebuf);
 
 	{
 		extern int pcic_nmi_trap_patch[4];
@@ -477,7 +478,7 @@ static void pcic_map_pci_device(struct linux_pcic *pcic,
 	int j;
 
 	if (node == 0 || node == -1) {
-		strcpy(namebuf, "???");
+		strscpy(namebuf, "???");
 	} else {
 		prom_getstring(node, "name", namebuf, 63); namebuf[63] = 0;
 	}
@@ -536,7 +537,7 @@ pcic_fill_irq(struct linux_pcic *pcic, struct pci_dev *dev, int node)
 	char namebuf[64];
 
 	if (node == 0 || node == -1) {
-		strcpy(namebuf, "???");
+		strscpy(namebuf, "???");
 	} else {
 		prom_getstring(node, "name", namebuf, sizeof(namebuf));
 	}
Signature · 1 line
2.51.0
maintainer
#2 lore raw
Quoted 5 lines · Bjorn Helgaas
Quoted 4 lines · Thorsten Blum

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

No functional changes intended.

Quoted 8 lines
Quoted 2 lines

No objection from me, but no particular PCI core issue and I don't maintain this file, so up to the sparc folks if they want it.

I would consider making a single patch to address this issue everywhere in arch/sparc so it can all be reviewed together.

Thank you and sorry for the late feedback. I agree with the above. Thorsten, could you fix this for all occurrences of strcpy() in arch/sparc?

Thanks,
Andreas

#3 lore raw

Hi Andreas,

Quoted 14 lines · Andreas Larsson
Quoted 11 lines · Bjorn Helgaas
Quoted 6 lines · Thorsten Blum

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

No functional changes intended.

No objection from me, but no particular PCI core issue and I don't maintain this file, so up to the sparc folks if they want it.

Quoted 6 lines
Quoted 2 lines

I would consider making a single patch to address this issue everywhere in arch/sparc so it can all be reviewed together.

Thank you and sorry for the late feedback. I agree with the above. Thorsten, could you fix this for all occurrences of strcpy() in arch/sparc?

I just submitted a small series [1] replacing all occurrences of strcpy in arch/sparc.

Thanks,
Thorsten

[1] https://lore.kernel.org/lkml/[email protected]/