Skip to contentSkip to conversation

MIPS: sgi-ip22: Replace deprecated strcpy() in plat_mem_setup()

PATCH Applied Thorsten Blum 4 participants 24 messages Aug 17, 2025 – Aug 29, 2025

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

PATCH 1/8 MIPS: sgi-ip22: Replace deprecated strcpy() in plat_mem_setup()

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

---
 arch/mips/sgi-ip22/ip22-setup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/mips/sgi-ip22/ip22-setup.c +2 -1
index e06a818fe792..f083b25be13b 100644
@@ -11,6 +11,7 @@
 #include <linux/types.h>
 #include <linux/console.h>
 #include <linux/sched.h>
+#include <linux/string.h>
 #include <linux/tty.h>
 
 #include <asm/addrspace.h>
@@ -65,7 +66,7 @@ void __init plat_mem_setup(void)
 		static char options[8] __initdata;
 		char *baud = ArcGetEnvironmentVariable("dbaud");
 		if (baud)
-			strcpy(options, baud);
+			strscpy(options, baud);
 		add_preferred_console("ttyS", *(ctype + 1) == '2' ? 1 : 0,
 				      baud ? options : NULL);
 	} else if (!ctype || *ctype != 'g') {
Signature · 1 line
2.50.1
#1 lore raw

PATCH 2/8 MIPS: sgi-ip32: Replace deprecated strcpy() in plat_mem_setup()

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

---
 arch/mips/sgi-ip32/ip32-setup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/mips/sgi-ip32/ip32-setup.c +2 -1
index aeb0805aae57..c2ebc4bbd866 100644
@@ -14,6 +14,7 @@
 #include <linux/interrupt.h>
 #include <linux/param.h>
 #include <linux/sched.h>
+#include <linux/string.h>
 
 #include <asm/bootinfo.h>
 #include <asm/mipsregs.h>
@@ -90,7 +91,7 @@ void __init plat_mem_setup(void)
 			static char options[8] __initdata;
 			char *baud = ArcGetEnvironmentVariable("dbaud");
 			if (baud)
-				strcpy(options, baud);
+				strscpy(options, baud);
 			add_preferred_console("ttyS", *(con + 1) == '2' ? 1 : 0,
 					      baud ? options : NULL);
 		}
Signature · 1 line
2.50.1
#2 lore raw

Re: [PATCH 2/8] MIPS: sgi-ip32: Replace deprecated strcpy() in plat_mem_setup()

Hi,

Quoted 13 lines · Thorsten Blum

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

---
 arch/mips/sgi-ip32/ip32-setup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/mips/sgi-ip32/ip32-setup.c +0 -0
index aeb0805aae57..c2ebc4bbd866 100644

arch/mips/sgi-ip32/ip32-setup.c line 17

Quoted 4 lines
arch/mips/sgi-ip32/ip32-setup.c +1 -0
@@ -14,6 +14,7 @@
 #include <linux/interrupt.h>
 #include <linux/param.h>
 #include <linux/sched.h>
+#include <linux/string.h>

This new include isn't strictly necessary as it was building with strcpy() fine before?

Quoted 16 lines
arch/mips/sgi-ip32/ip32-setup.c +1 -1
 #include <asm/bootinfo.h>
 #include <asm/mipsregs.h>
@@ -90,7 +91,7 @@ void __init plat_mem_setup(void)
 			static char options[8] __initdata;
 			char *baud = ArcGetEnvironmentVariable("dbaud");
 			if (baud)
-				strcpy(options, baud);
+				strscpy(options, baud);
 			add_preferred_console("ttyS", *(con + 1) == '2' ? 1 : 0,
 					      baud ? options : NULL);
 		}
Signature · 1 line
2.50.1

Thanks
Justin

#3 lore raw

Re: [PATCH 2/8] MIPS: sgi-ip32: Replace deprecated strcpy() in plat_mem_setup()

Quoted 9 lines · Justin Stitt
Quoted 8 lines · Thorsten Blum

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

---
arch/mips/sgi-ip32/ip32-setup.c | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 12 lines

arch/mips/sgi-ip32/ip32-setup.c line 17

Quoted 9 lines
arch/mips/sgi-ip32/ip32-setup.c +1 -0
index aeb0805aae57..c2ebc4bbd866 100644
@@ -14,6 +14,7 @@
 #include <linux/interrupt.h>
 #include <linux/param.h>
 #include <linux/sched.h>
+#include <linux/string.h>

This new include isn't strictly necessary as it was building with strcpy() fine before?

It's not strictly necessary, but since I was often asked to explicitly include it, I made it a habit.

Best,
Thorsten

maintainer Applied
#4 lore raw

Re: [PATCH 2/8] MIPS: sgi-ip32: Replace deprecated strcpy() in plat_mem_setup()

In reply to Thorsten Blum
Quoted 31 lines · Thorsten Blum

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

---
 arch/mips/sgi-ip32/ip32-setup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/mips/sgi-ip32/ip32-setup.c +2 -1
index aeb0805aae57..c2ebc4bbd866 100644
@@ -14,6 +14,7 @@
 #include <linux/interrupt.h>
 #include <linux/param.h>
 #include <linux/sched.h>
+#include <linux/string.h>
 
 #include <asm/bootinfo.h>
 #include <asm/mipsregs.h>
@@ -90,7 +91,7 @@ void __init plat_mem_setup(void)
 			static char options[8] __initdata;
 			char *baud = ArcGetEnvironmentVariable("dbaud");
 			if (baud)
-				strcpy(options, baud);
+				strscpy(options, baud);
 			add_preferred_console("ttyS", *(con + 1) == '2' ? 1 : 0,
 					      baud ? options : NULL);
 		}
Signature · 1 line
2.50.1

applied to mips-next.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]
#5 lore raw

PATCH 3/8 MIPS: sni: Replace deprecated strcpy() in sni_console_setup()

In reply to Thorsten Blum

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

---
 arch/mips/sni/setup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/mips/sni/setup.c +2 -1
index 03cb69937258..fc7da12284f5 100644
@@ -13,6 +13,7 @@
 #include <linux/export.h>
 #include <linux/console.h>
 #include <linux/screen_info.h>
+#include <linux/string.h>
 
 #ifdef CONFIG_FW_ARC
 #include <asm/fw/arc/types.h>
@@ -80,7 +81,7 @@ static void __init sni_console_setup(void)
 			break;
 		}
 		if (baud)
-			strcpy(options, baud);
+			strscpy(options, baud);
 		if (strncmp(cdev, "tty552", 6) == 0)
 			add_preferred_console("ttyS", port,
 					      baud ? options : NULL);
Signature · 1 line
2.50.1
Reviewed-by on v1 3/8
#6 lore raw

Re: [PATCH 3/8] MIPS: sni: Replace deprecated strcpy() in sni_console_setup()

Hi,

Quoted 13 lines · Thorsten Blum

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

---
 arch/mips/sni/setup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/mips/sni/setup.c +0 -0
index 03cb69937258..fc7da12284f5 100644

arch/mips/sni/setup.c line 16

Quoted 4 lines
arch/mips/sni/setup.c +1 -0
@@ -13,6 +13,7 @@
 #include <linux/export.h>
 #include <linux/console.h>
 #include <linux/screen_info.h>
+#include <linux/string.h>

This include isn't strictly necessary but I suppose it makes the dependency explicit.

Quoted 16 lines
arch/mips/sni/setup.c +1 -1
 #ifdef CONFIG_FW_ARC
 #include <asm/fw/arc/types.h>
@@ -80,7 +81,7 @@ static void __init sni_console_setup(void)
 			break;
 		}
 		if (baud)
-			strcpy(options, baud);
+			strscpy(options, baud);
 		if (strncmp(cdev, "tty552", 6) == 0)
 			add_preferred_console("ttyS", port,
 					      baud ? options : NULL);
Signature · 1 line
2.50.1

Thanks
Justin

maintainer Applied
#7 lore raw

Re: [PATCH 3/8] MIPS: sni: Replace deprecated strcpy() in sni_console_setup()

In reply to Thorsten Blum
Quoted 31 lines · Thorsten Blum

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

---
 arch/mips/sni/setup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/mips/sni/setup.c +2 -1
index 03cb69937258..fc7da12284f5 100644
@@ -13,6 +13,7 @@
 #include <linux/export.h>
 #include <linux/console.h>
 #include <linux/screen_info.h>
+#include <linux/string.h>
 
 #ifdef CONFIG_FW_ARC
 #include <asm/fw/arc/types.h>
@@ -80,7 +81,7 @@ static void __init sni_console_setup(void)
 			break;
 		}
 		if (baud)
-			strcpy(options, baud);
+			strscpy(options, baud);
 		if (strncmp(cdev, "tty552", 6) == 0)
 			add_preferred_console("ttyS", port,
 					      baud ? options : NULL);
Signature · 1 line
2.50.1

applied to mips-next.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]
#8 lore raw

PATCH 4/8 MIPS: txx9: Replace deprecated strcpy() with strscpy()

In reply to Thorsten Blum

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

---
 arch/mips/txx9/generic/setup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/txx9/generic/setup.c +2 -2
index 5dc867ea2c69..03f8a3a95637 100644
@@ -200,7 +200,7 @@ static void __init preprocess_cmdline(void)
 	static char cmdline[COMMAND_LINE_SIZE] __initdata;
 	char *s;
 
-	strcpy(cmdline, arcs_cmdline);
+	strscpy(cmdline, arcs_cmdline);
 	s = cmdline;
 	arcs_cmdline[0] = '\0';
 	while (s && *s) {
@@ -270,7 +270,7 @@ void __init prom_init(void)
 	preprocess_cmdline();
 	select_board();
 
-	strcpy(txx9_system_type, txx9_board_vec->system);
+	strscpy(txx9_system_type, txx9_board_vec->system);
 
 	txx9_board_vec->prom_init();
 }
Signature · 1 line
2.50.1
Reviewed-by on v1 4/8
#9 lore raw

Re: [PATCH 4/8] MIPS: txx9: Replace deprecated strcpy() with strscpy()

Quoted 4 lines · Thorsten Blum

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

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
maintainer Applied
#10 lore raw

Re: [PATCH 4/8] MIPS: txx9: Replace deprecated strcpy() with strscpy()

In reply to Thorsten Blum
Quoted 32 lines · Thorsten Blum

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

---
 arch/mips/txx9/generic/setup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/txx9/generic/setup.c +2 -2
index 5dc867ea2c69..03f8a3a95637 100644
@@ -200,7 +200,7 @@ static void __init preprocess_cmdline(void)
 	static char cmdline[COMMAND_LINE_SIZE] __initdata;
 	char *s;
 
-	strcpy(cmdline, arcs_cmdline);
+	strscpy(cmdline, arcs_cmdline);
 	s = cmdline;
 	arcs_cmdline[0] = '\0';
 	while (s && *s) {
@@ -270,7 +270,7 @@ void __init prom_init(void)
 	preprocess_cmdline();
 	select_board();
 
-	strcpy(txx9_system_type, txx9_board_vec->system);
+	strscpy(txx9_system_type, txx9_board_vec->system);
 
 	txx9_board_vec->prom_init();
 }
Signature · 1 line
2.50.1

applied to mips-next.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]
#11 lore raw

PATCH 5/8 MIPS: arc: Replace deprecated strcpy() with memcpy()

In reply to Thorsten Blum

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

Use pr_debug() instead of printk(KERN_DEBUG) to silence a checkpatch warning.

---
 arch/mips/fw/arc/cmdline.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
arch/mips/fw/arc/cmdline.c +13 -9
index 155c5e911723..86b0e377b713 100644
@@ -42,12 +42,13 @@ static char __init *move_firmware_args(int argc, LONG *argv, char *cp)
 {
 	char *s;
 	int actr, i;
+	size_t len;
 
 	actr = 1; /* Always ignore argv[0] */
 
 	while (actr < argc) {
-		for(i = 0; i < ARRAY_SIZE(used_arc); i++) {
-			int len = strlen(used_arc[i][0]);
+		for (i = 0; i < ARRAY_SIZE(used_arc); i++) {
+			len = strlen(used_arc[i][0]);
 
 			if (!strncmp(prom_argv(actr), used_arc[i][0], len)) {
 			/* Ok, we want it. First append the replacement... */
@@ -57,8 +58,9 @@ static char __init *move_firmware_args(int argc, LONG *argv, char *cp)
 				s = strchr(prom_argv(actr), '=');
 				if (s) {
 					s++;
-					strcpy(cp, s);
-					cp += strlen(s);
+					len = strlen(s);
+					memcpy(cp, s, len + 1);
+					cp += len;
 				}
 				*cp++ = ' ';
 				break;
@@ -74,6 +76,7 @@ void __init prom_init_cmdline(int argc, LONG *argv)
 {
 	char *cp;
 	int actr, i;
+	size_t len;
 
 	actr = 1; /* Always ignore argv[0] */
 
@@ -86,14 +89,15 @@ void __init prom_init_cmdline(int argc, LONG *argv)
 
 	while (actr < argc) {
 		for (i = 0; i < ARRAY_SIZE(ignored); i++) {
-			int len = strlen(ignored[i]);
-
+			len = strlen(ignored[i]);
 			if (!strncmp(prom_argv(actr), ignored[i], len))
 				goto pic_cont;
 		}
+
 		/* Ok, we want it. */
-		strcpy(cp, prom_argv(actr));
-		cp += strlen(prom_argv(actr));
+		len = strlen(prom_argv(actr));
+		memcpy(cp, prom_argv(actr), len + 1);
+		cp += len;
 		*cp++ = ' ';
 
 	pic_cont:
@@ -105,6 +109,6 @@ void __init prom_init_cmdline(int argc, LONG *argv)
 	*cp = '\0';
 
 #ifdef DEBUG_CMDLINE
-	printk(KERN_DEBUG "prom cmdline: %s\n", arcs_cmdline);
+	pr_debug("prom cmdline: %s\n", arcs_cmdline);
 #endif
 }
Signature · 1 line
2.50.1
#12 lore raw

Re: [PATCH 5/8] MIPS: arc: Replace deprecated strcpy() with memcpy()

Hi,

Quoted 4 lines · Thorsten Blum

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

Use pr_debug() instead of printk(KERN_DEBUG) to silence a checkpatch warning.

I'd like to see more reasoning for why you chose memcpy() here. With api refactors like this I think most folks want to know if 1) there is any functional change and 2) why you chose the api.

Quoted 79 lines
---
 arch/mips/fw/arc/cmdline.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
arch/mips/fw/arc/cmdline.c +13 -9
index 155c5e911723..86b0e377b713 100644
@@ -42,12 +42,13 @@ static char __init *move_firmware_args(int argc, LONG *argv, char *cp)
 {
 	char *s;
 	int actr, i;
+	size_t len;
 
 	actr = 1; /* Always ignore argv[0] */
 
 	while (actr < argc) {
-		for(i = 0; i < ARRAY_SIZE(used_arc); i++) {
-			int len = strlen(used_arc[i][0]);
+		for (i = 0; i < ARRAY_SIZE(used_arc); i++) {
+			len = strlen(used_arc[i][0]);
 
 			if (!strncmp(prom_argv(actr), used_arc[i][0], len)) {
 			/* Ok, we want it. First append the replacement... */
@@ -57,8 +58,9 @@ static char __init *move_firmware_args(int argc, LONG *argv, char *cp)
 				s = strchr(prom_argv(actr), '=');
 				if (s) {
 					s++;
-					strcpy(cp, s);
-					cp += strlen(s);
+					len = strlen(s);
+					memcpy(cp, s, len + 1);
+					cp += len;
 				}
 				*cp++ = ' ';
 				break;
@@ -74,6 +76,7 @@ void __init prom_init_cmdline(int argc, LONG *argv)
 {
 	char *cp;
 	int actr, i;
+	size_t len;
 
 	actr = 1; /* Always ignore argv[0] */
 
@@ -86,14 +89,15 @@ void __init prom_init_cmdline(int argc, LONG *argv)
 
 	while (actr < argc) {
 		for (i = 0; i < ARRAY_SIZE(ignored); i++) {
-			int len = strlen(ignored[i]);
-
+			len = strlen(ignored[i]);
 			if (!strncmp(prom_argv(actr), ignored[i], len))
 				goto pic_cont;
 		}
+
 		/* Ok, we want it. */
-		strcpy(cp, prom_argv(actr));
-		cp += strlen(prom_argv(actr));
+		len = strlen(prom_argv(actr));
+		memcpy(cp, prom_argv(actr), len + 1);
+		cp += len;
 		*cp++ = ' ';
 
 	pic_cont:
@@ -105,6 +109,6 @@ void __init prom_init_cmdline(int argc, LONG *argv)
 	*cp = '\0';
 
 #ifdef DEBUG_CMDLINE
-	printk(KERN_DEBUG "prom cmdline: %s\n", arcs_cmdline);
+	pr_debug("prom cmdline: %s\n", arcs_cmdline);
 #endif
 }
Signature · 1 line
2.50.1

Thanks
Justin

#13 lore raw

Re: [PATCH 5/8] MIPS: arc: Replace deprecated strcpy() with memcpy()

Hi Justin,

Quoted 9 lines · Justin Stitt
Quoted 4 lines · Thorsten Blum

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

Use pr_debug() instead of printk(KERN_DEBUG) to silence a checkpatch warning.

I'd like to see more reasoning for why you chose memcpy() here. With api refactors like this I think most folks want to know if 1) there is any functional change and 2) why you chose the api.

1) No functional changes intended.

2) To advance the pointer 'cp', we already determine the string length 'len' using strlen(), which allows us to use memcpy() directly. This is slightly more efficient than strscpy(), which would recompute the length before calling memcpy() internally. We could also use strscpy() and its return value as the length, but that would require checking for string truncation, which might introduce a functional change.

Thanks,
Thorsten

maintainer Applied
#14 lore raw

Re: [PATCH 5/8] MIPS: arc: Replace deprecated strcpy() with memcpy()

In reply to Thorsten Blum
Quoted 81 lines · Thorsten Blum

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

Use pr_debug() instead of printk(KERN_DEBUG) to silence a checkpatch warning.

---
 arch/mips/fw/arc/cmdline.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
arch/mips/fw/arc/cmdline.c +13 -9
index 155c5e911723..86b0e377b713 100644
@@ -42,12 +42,13 @@ static char __init *move_firmware_args(int argc, LONG *argv, char *cp)
 {
 	char *s;
 	int actr, i;
+	size_t len;
 
 	actr = 1; /* Always ignore argv[0] */
 
 	while (actr < argc) {
-		for(i = 0; i < ARRAY_SIZE(used_arc); i++) {
-			int len = strlen(used_arc[i][0]);
+		for (i = 0; i < ARRAY_SIZE(used_arc); i++) {
+			len = strlen(used_arc[i][0]);
 
 			if (!strncmp(prom_argv(actr), used_arc[i][0], len)) {
 			/* Ok, we want it. First append the replacement... */
@@ -57,8 +58,9 @@ static char __init *move_firmware_args(int argc, LONG *argv, char *cp)
 				s = strchr(prom_argv(actr), '=');
 				if (s) {
 					s++;
-					strcpy(cp, s);
-					cp += strlen(s);
+					len = strlen(s);
+					memcpy(cp, s, len + 1);
+					cp += len;
 				}
 				*cp++ = ' ';
 				break;
@@ -74,6 +76,7 @@ void __init prom_init_cmdline(int argc, LONG *argv)
 {
 	char *cp;
 	int actr, i;
+	size_t len;
 
 	actr = 1; /* Always ignore argv[0] */
 
@@ -86,14 +89,15 @@ void __init prom_init_cmdline(int argc, LONG *argv)
 
 	while (actr < argc) {
 		for (i = 0; i < ARRAY_SIZE(ignored); i++) {
-			int len = strlen(ignored[i]);
-
+			len = strlen(ignored[i]);
 			if (!strncmp(prom_argv(actr), ignored[i], len))
 				goto pic_cont;
 		}
+
 		/* Ok, we want it. */
-		strcpy(cp, prom_argv(actr));
-		cp += strlen(prom_argv(actr));
+		len = strlen(prom_argv(actr));
+		memcpy(cp, prom_argv(actr), len + 1);
+		cp += len;
 		*cp++ = ' ';
 
 	pic_cont:
@@ -105,6 +109,6 @@ void __init prom_init_cmdline(int argc, LONG *argv)
 	*cp = '\0';
 
 #ifdef DEBUG_CMDLINE
-	printk(KERN_DEBUG "prom cmdline: %s\n", arcs_cmdline);
+	pr_debug("prom cmdline: %s\n", arcs_cmdline);
 #endif
 }
Signature · 1 line
2.50.1

applied to mips-next.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]
#15 lore raw

PATCH 6/8 MIPS: octeon: Replace memset(0) + deprecated strcpy() with strscpy_pad()

In reply to Thorsten Blum

Replace memset(0) followed by the deprecated strcpy() with strscpy_pad() to improve octeon_fdt_set_phy(). This avoids zeroing the memory before copying the string and ensures the destination buffer is only written to once, simplifying the code and improving efficiency.

---
 arch/mips/cavium-octeon/octeon-platform.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/cavium-octeon/octeon-platform.c +2 -2
index 5e1dd4e6e82f..47677b5d7ed0 100644
@@ -13,6 +13,7 @@
 #include <linux/of_fdt.h>
 #include <linux/platform_device.h>
 #include <linux/libfdt.h>
+#include <linux/string.h>
 
 #include <asm/octeon/octeon.h>
 #include <asm/octeon/cvmx-helper-board.h>
@@ -538,8 +539,7 @@ static void __init octeon_fdt_set_phy(int eth, int phy_addr)
 
 	if (octeon_has_88e1145()) {
 		fdt_nop_property(initial_boot_params, phy, "marvell,reg-init");
-		memset(new_name, 0, sizeof(new_name));
-		strcpy(new_name, "marvell,88e1145");
+		strscpy_pad(new_name, "marvell,88e1145");
 		p = fdt_getprop(initial_boot_params, phy, "compatible",
 				&current_len);
 		if (p && current_len >= strlen(new_name))
Signature · 1 line
2.50.1
Reviewed-by on v1 6/8
#16 lore raw

Re: [PATCH 6/8] MIPS: octeon: Replace memset(0) + deprecated strcpy() with strscpy_pad()

Hi,

Quoted 7 lines · Thorsten Blum

Replace memset(0) followed by the deprecated strcpy() with strscpy_pad() to improve octeon_fdt_set_phy(). This avoids zeroing the memory before copying the string and ensures the destination buffer is only written to once, simplifying the code and improving efficiency.

Quoted 30 lines
---
 arch/mips/cavium-octeon/octeon-platform.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/cavium-octeon/octeon-platform.c +2 -2
index 5e1dd4e6e82f..47677b5d7ed0 100644
@@ -13,6 +13,7 @@
 #include <linux/of_fdt.h>
 #include <linux/platform_device.h>
 #include <linux/libfdt.h>
+#include <linux/string.h>
 
 #include <asm/octeon/octeon.h>
 #include <asm/octeon/cvmx-helper-board.h>
@@ -538,8 +539,7 @@ static void __init octeon_fdt_set_phy(int eth, int phy_addr)
 
 	if (octeon_has_88e1145()) {
 		fdt_nop_property(initial_boot_params, phy, "marvell,reg-init");
-		memset(new_name, 0, sizeof(new_name));
-		strcpy(new_name, "marvell,88e1145");
+		strscpy_pad(new_name, "marvell,88e1145");
 		p = fdt_getprop(initial_boot_params, phy, "compatible",
 				&current_len);
 		if (p && current_len >= strlen(new_name))
Signature · 1 line
2.50.1

Thanks
Justin

maintainer Applied
#17 lore raw

Re: [PATCH 6/8] MIPS: octeon: Replace memset(0) + deprecated strcpy() with strscpy_pad()

In reply to Thorsten Blum
Quoted 35 lines · Thorsten Blum

Replace memset(0) followed by the deprecated strcpy() with strscpy_pad() to improve octeon_fdt_set_phy(). This avoids zeroing the memory before copying the string and ensures the destination buffer is only written to once, simplifying the code and improving efficiency.

---
 arch/mips/cavium-octeon/octeon-platform.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/cavium-octeon/octeon-platform.c +2 -2
index 5e1dd4e6e82f..47677b5d7ed0 100644
@@ -13,6 +13,7 @@
 #include <linux/of_fdt.h>
 #include <linux/platform_device.h>
 #include <linux/libfdt.h>
+#include <linux/string.h>
 
 #include <asm/octeon/octeon.h>
 #include <asm/octeon/cvmx-helper-board.h>
@@ -538,8 +539,7 @@ static void __init octeon_fdt_set_phy(int eth, int phy_addr)
 
 	if (octeon_has_88e1145()) {
 		fdt_nop_property(initial_boot_params, phy, "marvell,reg-init");
-		memset(new_name, 0, sizeof(new_name));
-		strcpy(new_name, "marvell,88e1145");
+		strscpy_pad(new_name, "marvell,88e1145");
 		p = fdt_getprop(initial_boot_params, phy, "compatible",
 				&current_len);
 		if (p && current_len >= strlen(new_name))
Signature · 1 line
2.50.1

applied to mips-next.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]
#18 lore raw

PATCH 7/8 MIPS: octeon: Replace deprecated strcpy() in octeon_model_get_string_buffer()

In reply to Thorsten Blum

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

---
 .../cavium-octeon/executive/octeon-model.c    | 31 ++++++++++---------
 1 file changed, 16 insertions(+), 15 deletions(-)
arch/mips/cavium-octeon/executive/octeon-model.c +16 -15
index 657dbad9644e..98996cc0857e 100644
@@ -25,6 +25,7 @@
  * Contact Cavium Networks for more information
  ***********************license end**************************************/
 
+#include <linux/string.h>
 #include <asm/octeon/octeon.h>
 
 enum octeon_feature_bits __octeon_feature_bits __read_mostly;
@@ -208,16 +209,16 @@ static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
 		 */
 		switch (chip_id & 0xf) {
 		case 0:
-			strcpy(pass, "1.X");
+			strscpy(pass, "1.X");
 			break;
 		case 1:
-			strcpy(pass, "2.X");
+			strscpy(pass, "2.X");
 			break;
 		case 3:
-			strcpy(pass, "3.X");
+			strscpy(pass, "3.X");
 			break;
 		default:
-			strcpy(pass, "X.X");
+			strscpy(pass, "X.X");
 			break;
 		}
 		break;
@@ -232,13 +233,13 @@ static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
 		 */
 		switch (chip_id & 0xf) {
 		case 0:
-			strcpy(pass, "1.0");
+			strscpy(pass, "1.0");
 			break;
 		case 2:
-			strcpy(pass, "1.1");
+			strscpy(pass, "1.1");
 			break;
 		default:
-			strcpy(pass, "X.X");
+			strscpy(pass, "X.X");
 			break;
 		}
 		break;
@@ -253,13 +254,13 @@ static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
 		 */
 		switch (chip_id & 0xf) {
 		case 0:
-			strcpy(pass, "1.0");
+			strscpy(pass, "1.0");
 			break;
 		case 2:
-			strcpy(pass, "1.1");
+			strscpy(pass, "1.1");
 			break;
 		default:
-			strcpy(pass, "X.X");
+			strscpy(pass, "X.X");
 			break;
 		}
 		break;
@@ -273,16 +274,16 @@ static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
 		if ((chip_id & 0xFF) < 0x8) {
 			switch (chip_id & 0x3) {
 			case 0:
-				strcpy(pass, "1.0");
+				strscpy(pass, "1.0");
 				break;
 			case 1:
-				strcpy(pass, "1.1");
+				strscpy(pass, "1.1");
 				break;
 			case 3:
-				strcpy(pass, "1.2");
+				strscpy(pass, "1.2");
 				break;
 			default:
-				strcpy(pass, "1.X");
+				strscpy(pass, "1.X");
 				break;
 			}
 		}
@@ -447,7 +448,7 @@ static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
 	default:
 		family = "XX";
 		core_model = "XX";
-		strcpy(pass, "X.X");
+		strscpy(pass, "X.X");
 		suffix = "XXX";
 		break;
 	}
Signature · 1 line
2.50.1
maintainer Applied
#19 lore raw

Re: [PATCH 7/8] MIPS: octeon: Replace deprecated strcpy() in octeon_model_get_string_buffer()

Quoted 107 lines · Thorsten Blum

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

---
 .../cavium-octeon/executive/octeon-model.c    | 31 ++++++++++---------
 1 file changed, 16 insertions(+), 15 deletions(-)
arch/mips/cavium-octeon/executive/octeon-model.c +16 -15
index 657dbad9644e..98996cc0857e 100644
@@ -25,6 +25,7 @@
  * Contact Cavium Networks for more information
  ***********************license end**************************************/
 
+#include <linux/string.h>
 #include <asm/octeon/octeon.h>
 
 enum octeon_feature_bits __octeon_feature_bits __read_mostly;
@@ -208,16 +209,16 @@ static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
 		 */
 		switch (chip_id & 0xf) {
 		case 0:
-			strcpy(pass, "1.X");
+			strscpy(pass, "1.X");
 			break;
 		case 1:
-			strcpy(pass, "2.X");
+			strscpy(pass, "2.X");
 			break;
 		case 3:
-			strcpy(pass, "3.X");
+			strscpy(pass, "3.X");
 			break;
 		default:
-			strcpy(pass, "X.X");
+			strscpy(pass, "X.X");
 			break;
 		}
 		break;
@@ -232,13 +233,13 @@ static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
 		 */
 		switch (chip_id & 0xf) {
 		case 0:
-			strcpy(pass, "1.0");
+			strscpy(pass, "1.0");
 			break;
 		case 2:
-			strcpy(pass, "1.1");
+			strscpy(pass, "1.1");
 			break;
 		default:
-			strcpy(pass, "X.X");
+			strscpy(pass, "X.X");
 			break;
 		}
 		break;
@@ -253,13 +254,13 @@ static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
 		 */
 		switch (chip_id & 0xf) {
 		case 0:
-			strcpy(pass, "1.0");
+			strscpy(pass, "1.0");
 			break;
 		case 2:
-			strcpy(pass, "1.1");
+			strscpy(pass, "1.1");
 			break;
 		default:
-			strcpy(pass, "X.X");
+			strscpy(pass, "X.X");
 			break;
 		}
 		break;
@@ -273,16 +274,16 @@ static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
 		if ((chip_id & 0xFF) < 0x8) {
 			switch (chip_id & 0x3) {
 			case 0:
-				strcpy(pass, "1.0");
+				strscpy(pass, "1.0");
 				break;
 			case 1:
-				strcpy(pass, "1.1");
+				strscpy(pass, "1.1");
 				break;
 			case 3:
-				strcpy(pass, "1.2");
+				strscpy(pass, "1.2");
 				break;
 			default:
-				strcpy(pass, "1.X");
+				strscpy(pass, "1.X");
 				break;
 			}
 		}
@@ -447,7 +448,7 @@ static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
 	default:
 		family = "XX";
 		core_model = "XX";
-		strcpy(pass, "X.X");
+		strscpy(pass, "X.X");
 		suffix = "XXX";
 		break;
 	}
Signature · 1 line
2.50.1

applied to mips-next.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]
#20 lore raw

PATCH 8/8 MIPS: generic: Replace deprecated strcpy() in ocelot_detect()

In reply to Thorsten Blum

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

---
 arch/mips/generic/board-ocelot.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/mips/generic/board-ocelot.c +2 -1
index 7115410acb4f..59a0fb243582 100644
@@ -4,6 +4,7 @@
  *
  * Copyright (c) 2017 Microsemi Corporation
  */
+#include <linux/string.h>
 #include <asm/machine.h>
 #include <asm/prom.h>
 
@@ -41,7 +42,7 @@ static __init bool ocelot_detect(void)
 
 		if (prom_argc > 1 && strlen(prom_argv[1]) > 0)
 			/* ignore all built-in args if any f/w args given */
-			strcpy(arcs_cmdline, prom_argv[1]);
+			strscpy(arcs_cmdline, prom_argv[1]);
 	}
 
 	return true;
Signature · 1 line
2.50.1
maintainer Applied
#21 lore raw

Re: [PATCH 8/8] MIPS: generic: Replace deprecated strcpy() in ocelot_detect()

Quoted 31 lines · Thorsten Blum

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

---
 arch/mips/generic/board-ocelot.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/mips/generic/board-ocelot.c +2 -1
index 7115410acb4f..59a0fb243582 100644
@@ -4,6 +4,7 @@
  *
  * Copyright (c) 2017 Microsemi Corporation
  */
+#include <linux/string.h>
 #include <asm/machine.h>
 #include <asm/prom.h>
 
@@ -41,7 +42,7 @@ static __init bool ocelot_detect(void)
 
 		if (prom_argc > 1 && strlen(prom_argv[1]) > 0)
 			/* ignore all built-in args if any f/w args given */
-			strcpy(arcs_cmdline, prom_argv[1]);
+			strscpy(arcs_cmdline, prom_argv[1]);
 	}
 
 	return true;
Signature · 1 line
2.50.1

applied to mips-next.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]
Reviewed-by on v1 1/8
#22 lore raw
In reply to Thorsten Blum

Hi,

Quoted 4 lines · Thorsten Blum

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

Quoted 29 lines
---
 arch/mips/sgi-ip22/ip22-setup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/mips/sgi-ip22/ip22-setup.c +2 -1
index e06a818fe792..f083b25be13b 100644
@@ -11,6 +11,7 @@
 #include <linux/types.h>
 #include <linux/console.h>
 #include <linux/sched.h>
+#include <linux/string.h>
 #include <linux/tty.h>
 
 #include <asm/addrspace.h>
@@ -65,7 +66,7 @@ void __init plat_mem_setup(void)
 		static char options[8] __initdata;
 		char *baud = ArcGetEnvironmentVariable("dbaud");
 		if (baud)
-			strcpy(options, baud);
+			strscpy(options, baud);
 		add_preferred_console("ttyS", *(ctype + 1) == '2' ? 1 : 0,
 				      baud ? options : NULL);
 	} else if (!ctype || *ctype != 'g') {
Signature · 1 line
2.50.1

Thanks
Justin

maintainer Applied
#23 lore raw
In reply to Thorsten Blum
Quoted 31 lines · Thorsten Blum

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

---
 arch/mips/sgi-ip22/ip22-setup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/mips/sgi-ip22/ip22-setup.c +2 -1
index e06a818fe792..f083b25be13b 100644
@@ -11,6 +11,7 @@
 #include <linux/types.h>
 #include <linux/console.h>
 #include <linux/sched.h>
+#include <linux/string.h>
 #include <linux/tty.h>
 
 #include <asm/addrspace.h>
@@ -65,7 +66,7 @@ void __init plat_mem_setup(void)
 		static char options[8] __initdata;
 		char *baud = ArcGetEnvironmentVariable("dbaud");
 		if (baud)
-			strcpy(options, baud);
+			strscpy(options, baud);
 		add_preferred_console("ttyS", *(ctype + 1) == '2' ? 1 : 0,
 				      baud ? options : NULL);
 	} else if (!ctype || *ctype != 'g') {
Signature · 1 line
2.50.1

applied to mips-next.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]