Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792573088; b=Qhwhvcd2STGheZSKScbBO5Rn4nbbWy8L9LrgHun7Ss2Xiuc0mq8Prp/WQtUvc+EExJu5 gpPcBGt4oe3LuaJT6c8Uk9y4FP93CZGr8QzXxlrZ2uOG3NgwoV6Jhd9y/vlWM/m+4Nsn9 nnJLG8v2dB1G2nq667A+cdWXDTZqwyzZW6LplVAx5D+svPqS5Uek8cKnEfWfmrUoxmZ2k MRq346ITAF0JH1oUvDQlweYSiMtcel8eJ83PigAtgNlxLXycl1dpmuXGtLTWFMX/lJ6Jp iFAOMbsh9fL5Yr4bL801fO7+zdZiTO4OeiF4BBTMv1kRZpXJRWzqkFR3IKrhhmTQb/Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792573088; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:From:To:Cc: Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Authority-Analysis: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-ORIG-GUID: X-Proofpoint-Spam-Info:X-Proofpoint-GUID:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=2AfyFc0ogUfdrYyNRX9G1+SJ+Gxo1o57TnNd9vgut88=; b=RD1w/q3pFD7FUvfMXyAjdtsPF97sQt2uwSvmWcn5yKackZAO2IPvLNHirZMPqXoBOASs yNB/ZY5RIBlmeSo1P6Q6UDzHmkvxHQa2u7rL5+H44kJ3vcnfro2/w0cOplmlPtgTDdCJY JvPGhIFDI3QJYVVjYoNDWbIiJr0WHiVnGD6XoTwbWAmfR5+EXSQWxc4bnPznqFXWkh5Se /JeFURDGLioXsb8ylEVrMcHPuM/3j/DZ7NDCyrcCCpVSGiTL4ColfJ1+yQGAQetdtKMIO SYkXEd2aDqphdQ1Ps+52VO7QjTI+7lTNAszkWxxkuN+daCMwXQTBb21BypeV6fOwqZA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=gbmHNU7k; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=PhKd0apH; arc=none smtp.remote-ip=205.220.180.131 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C84C60A2609 for ; Wed, 21 Oct 2026 08:58:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2C84C60A2609 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=gbmHNU7k; dkim=pass (2048-bit key, unprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=PhKd0apH Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 69L5j02O165032 for ; Wed, 21 Oct 2026 08:58:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=2AfyFc0ogUf drYyNRX9G1+SJ+Gxo1o57TnNd9vgut88=; b=gbmHNU7kQbdNXFPXrzA8QJJo2CZ a42GcmLkNAmhRgxA0rgy/vM6nUJiUDYRiryxZRkTPDO7AdSiBeh7CvexixDNA/6c ISGYKWNKm9ObxCFzqHhhYuAePZLPaLpKUvBVtSu3bgzT630fa7PfYyw0fLPvYj6S 2TUyUCfEVL5hcvYyLZTS++vaNYLPEHKDgrtIo8C7tJwoVmBSAgjcXNP8MiOisesC vcdnQJoKnJkvGE3BKvTKriPn2dQyynSbHrL/cIIksjF7AnhpaWQsmwcKAbfdi1dh Jq6C8Rk5dRN2VewIjop8Ty4eJkqf5za68/ekn2P9HwvOKLIqro1xsyK5/cg== Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4hegs02b93-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 21 Oct 2026 08:58:06 +0000 (GMT) Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-934956beec8so108045585a.0 for ; Wed, 21 Oct 2026 01:58:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1792573086; x=1793177886; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=2AfyFc0ogUfdrYyNRX9G1+SJ+Gxo1o57TnNd9vgut88=; b=PhKd0apHDcO7HGXlquY/vh68RAcWKK0YnTRc6B2RfUSS/A127TaLP+PfnrR9/pTo/f ZPybIELJvJvWDmovFf+2/vibMHED2U0dPVytowVfXDDfMYEgFXi8a9zbDRTT06/Nukxz 50MLg92kyIFYazLZkPRh+O4nSYwjo65ma4K6KDK+yuVTNPRrsFMVWS3IBvFWtmUgJK+j FbxVaTQSVPdmA9JVuTIRsvbomkTipdG90ouysK8Bj7NfQKDQ2F5DEFPuR+QY7N3WXzVR asR3ZJHDwpeav6vda0ykOtv9Jalm6vc91xgku7PY0rWz113YkWAgopwqxdauaCgyXV3E KmsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792573086; x=1793177886; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=2AfyFc0ogUfdrYyNRX9G1+SJ+Gxo1o57TnNd9vgut88=; b=T1cGWVMftEHdBhmObnxl+iHjnOtyO1N2Rs64TkGaYGB9G9j/I3fp2sb//t+1S95jlA FUurZkovnJoRFvqjQ3B6zI4ZqWULLIKC8T3+lXyCOGxFL3m7gJBSvIcfPCBJN8Maj+rQ If1wd3wjIn3usAmdZBfpPJX1KUCFA/Cwzkyaw9RPeTGt9L1iHNWlPeQQVm+U5fBNGPiF ILfbNQU+iJ3I6AzA/darm8URnQi6ralztqNUMrmtXY9PS3gBjeLJKS0kZYo1rkzqZjwB BbR1xUXpjdfQ9cLtadhMB1GK0C+ev+S5GMIV+kQMQnHgDcshKlJ1xn9hgoj8/xOLHOWT Gy1g== X-Forwarded-Encrypted: i=1; AKwUvBxe5VI47M5ffPedmPVJ/tQnNfIhbL17eP5jzjBE36KuLX8IDd02RPhOoAHd4e4gN93VeBKC18IpPQOeavNS@vger.kernel.org X-Gm-Message-State: AFq9FYKA8+ZhWRUTKZNvu7+x+xR7E7oRmzDoeK2ys36zY3wEeMmYZhPP VVWEbPE+FkCMXYYh9k9xqRKUUPOFPJkgLucovIO/kCpuSP9FX2kCwqr+1s6w9Mm1z7kbxlmt/E0 2Eh37P5nneF3H5YGy9wVvE3X8vIpIywbabo3FWvNjazriHd16vUyctNFAIYs5T4STrSWS X-Gm-Gg: AYBFou1lf5jl92ruyZchhUnoq4uH0dT4HsgOVtvhE3fNwmjzo2l3ea3KqXpskBqhRrp GVLaoUtZ/k+nGquWu59GPgPC4In3/SZnBpZIKW6me08XUvhT8iGu9OWp7kcAHaD91EfiIGyMjaa 37sYKYDr8QUYSomsqEVUhzI+vrG9nLf7G0v+lmjUkKJP5HLHgmeazyVancIbYacah3utzeeuPXD rXZFSgcgoNvbKMQ0iqgpL34rPdwd/x90xdWx/eDPQGvylDGT8PafgrHGXv8Yuy/PVZwB60tSW5J fdmmwMrL8X71IoIUAWHh4cvzeJkKY0MqNkJ6e4LvlNIS0CCMiPyrHQlpoG+XYIkIe+JWTwgKwxM jPvFI0qlLByV0dkMal7hQfihmww== X-Received: by 2002:a05:620a:1b95:b0:93c:c162:125b with SMTP id af79cd13be357-93f57f233admr308222385a.39.1792573086389; Wed, 21 Oct 2026 01:58:06 -0700 (PDT) X-Received: by 2002:a05:620a:1b95:b0:93c:c162:125b with SMTP id af79cd13be357-93f57f233admr308220085a.39.1792573085975; Wed, 21 Oct 2026 01:58:05 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:8d9e:b00d:491:1503]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e258424bcsm4058401f8f.55.2026.10.21.01.58.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2026 01:58:04 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@oss.qualcomm.com Cc: andersson@kernel.org, Amit Kucheria , Thara Gopinath , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , linux-arm-msm@vger.kernel.org (open list:ARM/QUALCOMM MAILING LIST), linux-pm@vger.kernel.org (open list:QUALCOMM TSENS THERMAL DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 2/3] thermal/drivers/qcom/tsens: Validate the sensor count before initialization Date: Wed, 21 Oct 2026 10:57:47 +0200 Message-ID: <20261021085749.3786101-2-daniel.lezcano@oss.qualcomm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261021085749.3786101-1-daniel.lezcano@oss.qualcomm.com> References: <20261021085749.3786101-1-daniel.lezcano@oss.qualcomm.com> X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Authority-Analysis: v=2.4 cv=S/NMU4sP c=1 sm=1 tr=0 ts=6ad87e9e cx=c_pps a=hnmNkyzTK/kJ09Xio7VxxA==:117 a=xqWC_Br6kY4A:10 a=660iZSQnnn4A:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=c92rfblmAAAA:8 a=EUspDBNiAAAA:8 a=VwQbUJbxAAAA:8 a=Kcfep0Es--GOdI1On_cA:9 a=PEH46H7Ffwr30OY-TuGO:22 a=GvGzcOZaWPEFPQC_NcjD:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDIxMDAzNSBTYWx0ZWRfX4NQyA2NM4V/L Mejxlm+X6aQa6yHn+QzTevb0KKfU5IXZZtiJRt+5R0/51TO9ptWjxp/OB6N1xDSs9iAQO6Vqa9H Ly8GwzLwRhcbI3cB5L19sAPl1djqqk3VngkDiJwMwiQiVGCwA2fUGFbV9VtayqPmgDyt+OiaJbD DW53o9KSWhtJZPdsoMVc+XMhT+OXppXWwMtC4REG0YVBphN7Y4XuYcxuQO4R9GqoZS9BDfEeGgY gFT4qfIxBp3P/T4i+FSE8tcgfecHa8MxtFa7kjrTpNOPp3w0jugtHz+F7OWdV8tNGmqhsGgEYzI nRfxUJ9ZSGn2MIcJ/ZS8ovAFe0oDCcC25ivab/eIpN46UxqemUacAjLfhvLoOI5vRW4Ux2Q3jf6 qRT6To1uldMbRb/bBHwVpEEOn8/cmtiy5kJGXtZD+gqjECH5sctCZUBYnRBdrgxDERSofkN5AG0 4oItVbMYZkjDrzCI5gw== X-Proofpoint-ORIG-GUID: dENCrm6Qu7vpMmMvX9qmtVuJfHGZpMO4 X-Proofpoint-Spam-Info: AW1haW4tMjYxMDIxMDAzNSBTYWx0ZWRfX1RpiqrEm+XnT xP5Nysnvilo7tM0MLczgoUqc5PiZ+Ux3MRUv340cF6sNlmJRr7spvtjrZRn5bWLbjVviOBbeUSD P6GpygdZ984pX+Y2UFkpPfyMDrAKQMA= X-Proofpoint-GUID: dENCrm6Qu7vpMmMvX9qmtVuJfHGZpMO4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-10-21_02,2026-10-19_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1015 priorityscore=1501 spamscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 impostorscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610190000 definitions=main-2610210035 The #qcom,sensors property can override the platform sensor count without an upper-bound check. A count exceeding the IP's maximum causes the driver to access uninitialized regmap fields when handling interrupts. Platforms with an explicit hardware-ID table can also read beyond that table, even when the count remains within the IP's hardware limit. Reject zero counts and counts exceeding the hardware maximum or, when present, the hardware-ID table length before allocating the private structure and assigning sensor IDs. Preserve the existing fallback to the platform default when the property cannot be read, and document both the fallback and the sensor-count limits. Fixes: 6d7c70d1cd65 ("thermal: qcom: tsens: Allow number of sensors to come from DT") Closes: https://sashiko.dev/#/bug/linux-d0867095-c131-491e-a6aa-a81debfd0df5 Signed-off-by: Daniel Lezcano Cc: Bjorn Andersson --- drivers/thermal/qcom/tsens.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index 4f69ce4976d9..9134637a3458 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -1399,10 +1399,20 @@ static int tsens_probe_common(struct platform_device *pdev) num_sensors = data->num_sensors; + /* + * DT may override the platform sensor count. A missing, empty or too + * short property leaves num_sensors unchanged, retaining the default. + */ if (np) of_property_read_u32(np, "#qcom,sensors", &num_sensors); - if (num_sensors <= 0) { + /* + * Require at least one sensor and stay within the IP's hardware limit. + * Platforms with an explicit hardware-ID table also limit the count to + * its number of entries, which may be smaller than the hardware limit. + */ + if (!num_sensors || num_sensors > data->feat->max_sensors || + (data->hw_ids && num_sensors > data->num_sensors)) { dev_err(dev, "%s: invalid number of sensors\n", __func__); return -EINVAL; } -- 2.43.0