* [PATCH] powerpc/dt_cpu_ftrs: Avoid separate strlen() in scan_callback()
@ 2026-06-30 15:46 Thorsten Blum
0 siblings, 0 replies; only message in thread
From: Thorsten Blum @ 2026-06-30 15:46 UTC (permalink / raw)
To: Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP)
Cc: Thorsten Blum, linuxppc-dev, linux-kernel
Use the return value of strscpy() when copying the display name instead
of checking the source string length with strlen() first.
Keep dt_cpu_name static but move it into dt_cpu_ftrs_scan_callback(),
where it is assigned.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
arch/powerpc/kernel/dt_cpu_ftrs.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/kernel/dt_cpu_ftrs.c b/arch/powerpc/kernel/dt_cpu_ftrs.c
index 3af6c06af02f..8d8e94e4d2bc 100644
--- a/arch/powerpc/kernel/dt_cpu_ftrs.c
+++ b/arch/powerpc/kernel/dt_cpu_ftrs.c
@@ -90,8 +90,6 @@ static void __restore_cpu_cpufeatures(void)
init_pmu_registers();
}
-static char dt_cpu_name[64];
-
static struct cpu_spec __initdata base_cpu_spec = {
.cpu_name = NULL,
.cpu_features = CPU_FTRS_DT_CPU_BASE,
@@ -1069,6 +1067,7 @@ static int __init count_cpufeatures_subnodes(unsigned long node,
static int __init dt_cpu_ftrs_scan_callback(unsigned long node, const char
*uname, int depth, void *data)
{
+ static char dt_cpu_name[64];
const __be32 *prop;
int count, i;
u32 isa;
@@ -1106,10 +1105,8 @@ static int __init dt_cpu_ftrs_scan_callback(unsigned long node, const char
}
prop = of_get_flat_dt_prop(node, "display-name", NULL);
- if (prop && strlen((char *)prop) != 0) {
- strscpy(dt_cpu_name, (char *)prop, sizeof(dt_cpu_name));
+ if (prop && strscpy(dt_cpu_name, (char *)prop) != 0)
cur_cpu_spec->cpu_name = dt_cpu_name;
- }
cpufeatures_setup_finished();
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-06-30 15:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-30 15:46 [PATCH] powerpc/dt_cpu_ftrs: Avoid separate strlen() in scan_callback() Thorsten Blum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox