From nobody Mon Dec 15 23:28:19 2025 Received: from out-178.mta0.migadu.com (out-178.mta0.migadu.com [91.218.175.178]) (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 338FC14A60C for ; Mon, 15 Dec 2025 12:16:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765801022; cv=none; b=BAR8Yc8BbhlmbFQ5/1tjar/cW49cG2i5XQUHqHGIbv7/Q6c1k7VwM9LT7elZb8PQNLQ1PJ4P5M+uthFjp9h2jMKIfGOxvzj2ANEkxOiCyzxX76sJuAs9lnS3KRltDM45T+ThDkMEUERLDFQRv0HTn8oXbu9GcevhkJe+xs6P3hc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765801022; c=relaxed/simple; bh=xKd21L+BfgO9tYmMGuabt4dmULRVfJo5yaNtaQjm5Pw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=EWNvw3gV90JdICjx/JdIO6EUde3uOPVGTkVtnMTNVPAQ/TDcu4MEyeOYjWopEf9DQgGCDrbDRyo4ppEleT6LpsYhbifVmXv7Fi2WaFOcnB70adiH19WBbUJwykdapKyd/58jly31VIHwEdwe+6HudzeW0Da/w5JLE8Cyuj37e1M= 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=UM72Uxo2; arc=none smtp.client-ip=91.218.175.178 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="UM72Uxo2" 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=1765801012; 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=sSkpNYskDg1ZQG+F+jcVFB1gclBvY7a46b7Rerkj6PQ=; b=UM72Uxo2PjeXPtv3jtoZnqtxL8nS9iCxMcpkzcQRFsnRI4GzDPMPjN/sfEu5O2dUEQPlK2 hbfUsguSZPtdbJoNfECHI54EMsXWxITswFjN8Yx+orWD00OLuHiul3saFyUEx2li181C+l fio97nKfImBqHNdCCcYlmIS4nJK7l3E= From: Thorsten Blum To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba Cc: Thorsten Blum , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] thermal: core: Use strnlen in thermal_zone_device_register_with_trips Date: Mon, 15 Dec 2025 13:16:33 +0100 Message-ID: <20251215121633.375193-1-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Replace strlen() with the safer strnlen() and calculate the length of the thermal zone name 'type' only once. No functional changes. Signed-off-by: Thorsten Blum --- drivers/thermal/thermal_core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 17ca5c082643..63eb35b449c6 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1505,15 +1505,17 @@ thermal_zone_device_register_with_trips(const char = *type, const struct thermal_trip *trip =3D trips; struct thermal_zone_device *tz; struct thermal_trip_desc *td; + size_t type_len; int id; int result; =20 - if (!type || strlen(type) =3D=3D 0) { + type_len =3D type ? strnlen(type, THERMAL_NAME_LENGTH) : 0; + if (type_len =3D=3D 0) { pr_err("No thermal zone type defined\n"); return ERR_PTR(-EINVAL); } =20 - if (strlen(type) >=3D THERMAL_NAME_LENGTH) { + if (type_len =3D=3D THERMAL_NAME_LENGTH) { pr_err("Thermal zone name (%s) too long, should be under %d chars\n", type, THERMAL_NAME_LENGTH); return ERR_PTR(-EINVAL); --=20 Thorsten Blum GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4