Skip to content

Commit 2c7c8cf

Browse files
tobluxtsbogend
authored andcommitted
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: KSPP#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>
1 parent 267ac0a commit 2c7c8cf

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

arch/mips/cavium-octeon/octeon-platform.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/of_fdt.h>
1414
#include <linux/platform_device.h>
1515
#include <linux/libfdt.h>
16+
#include <linux/string.h>
1617

1718
#include <asm/octeon/octeon.h>
1819
#include <asm/octeon/cvmx-helper-board.h>
@@ -538,8 +539,7 @@ static void __init octeon_fdt_set_phy(int eth, int phy_addr)
538539

539540
if (octeon_has_88e1145()) {
540541
fdt_nop_property(initial_boot_params, phy, "marvell,reg-init");
541-
memset(new_name, 0, sizeof(new_name));
542-
strcpy(new_name, "marvell,88e1145");
542+
strscpy_pad(new_name, "marvell,88e1145");
543543
p = fdt_getprop(initial_boot_params, phy, "compatible",
544544
&current_len);
545545
if (p && current_len >= strlen(new_name))

0 commit comments

Comments
 (0)