From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-181.mta0.migadu.com (out-181.mta0.migadu.com [91.218.175.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 135D12C235E for ; Tue, 30 Jun 2026 15:47:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782834444; cv=none; b=HcOhgnH8+G54Ra5ABLEzrfL/wQEqreKIhgANSna56yQJCsHnigFfg5O5y9mdhJtF9JVnac9rfjLD4f/y6V0w6Z5CNTnLa/WPsDIBxMZAKVEWgh5yrPlLp+IDheSV6R/gQHnQDXxFboPKPwMQuqc2wrgIx8tmGrApy93ISeFZhSM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782834444; c=relaxed/simple; bh=jcM14XAg/Rn+w1ag3XGyVlqQz4Yn6TB6lSLVOHW5hJQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=TBkqAztwWzUfjGHASyZJrT6Qsrzzg+fjWAUuS+mV1kUWNg2u/hjz+nZOSAn9t2JWIqziHqkxBZsRPyMkRqvkeNzQypDELgIRR5W/snTF9zXr1w3G52UslJJ4VBYS/QJgRtuClWY1aIj23N8p7dTiFw1id84UfQCeRe683r8/Uoo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=AF0bM6Gn; arc=none smtp.client-ip=91.218.175.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="AF0bM6Gn" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1782834439; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=g0pf9ki1Ai0Xt9Gsq1JCPfcLfK6MHG0DE4RAET8G76Y=; b=AF0bM6GnVxIx4mkct6+9qn8H9JLXIiiPvkWChBIzRSXrpTasjDGtbyt8pYXrtPEe2LhIJ/ uCHZEc63/tqn+xmBYsX+nKKg4e0UAvUMU1GXYkLSsoTa9UuwpWKWRAIRXYAbJ6NpFb3+ep vjOEFRPrPT5jgvIYZ2USk06P350xXGQ= From: Thorsten Blum To: Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , "Christophe Leroy (CS GROUP)" Cc: Thorsten Blum , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH] powerpc/dt_cpu_ftrs: Avoid separate strlen() in scan_callback() Date: Tue, 30 Jun 2026 17:46:56 +0200 Message-ID: <20260630154657.693088-2-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1554; i=thorsten.blum@linux.dev; h=from:subject; bh=jcM14XAg/Rn+w1ag3XGyVlqQz4Yn6TB6lSLVOHW5hJQ=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDFnOTz4etmtf8Tt0d+YqhUOX2qY/mS761vib++ksxegMW TGT9BNrO0pZGMS4GGTFFFkezPoxw7e0pnKTScROmDmsTCBDGLg4BWAibLsZGY567HZcfyLE6Nb9 6vwXhnk1pdaevz8dnai1NOS/1k0H60RGhq6TJX/01suay8+7mvJtss35itTjk6w1/mnMvh9ZZuR ykA0A X-Developer-Key: i=thorsten.blum@linux.dev; a=openpgp; fpr=1D60735E8AEF3BE473B69D84733678FD8DFEEAD4 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 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 --- 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();