Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: octeon: Replace memset(0) + deprecated strcpy() with strscpy_pad()

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.

Link: https://github.com/KSPP/linux/issues/88
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Justin Stitt <justinstitt@google.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

Thorsten Blum and committed by
Thomas Bogendoerfer
2c7c8cf6 267ac0a8

+2 -2
+2 -2
arch/mips/cavium-octeon/octeon-platform.c
··· 13 13 #include <linux/of_fdt.h> 14 14 #include <linux/platform_device.h> 15 15 #include <linux/libfdt.h> 16 + #include <linux/string.h> 16 17 17 18 #include <asm/octeon/octeon.h> 18 19 #include <asm/octeon/cvmx-helper-board.h> ··· 539 538 540 539 if (octeon_has_88e1145()) { 541 540 fdt_nop_property(initial_boot_params, phy, "marvell,reg-init"); 542 - memset(new_name, 0, sizeof(new_name)); 543 - strcpy(new_name, "marvell,88e1145"); 541 + strscpy_pad(new_name, "marvell,88e1145"); 544 542 p = fdt_getprop(initial_boot_params, phy, "compatible", 545 543 &current_len); 546 544 if (p && current_len >= strlen(new_name))