Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp566262lqp; Fri, 5 Apr 2024 02:10:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVo6egu1tviJpb9DGStNOjKtZSq7h7AVNJf5KlQTZ16BcdGY6XQ5zL1F5jL4yL1PQgEHosmGFYBR0f6GWnxZxaNHOyxUnWFgSw9NnKbSA== X-Google-Smtp-Source: AGHT+IFbEslp4trpMPH7iXTa/drR25HeZrl37ky8dAfICLtwJfuW8PPxcWNho0NWEMvLQxpDtta/ X-Received: by 2002:a17:906:f20c:b0:a4e:9e94:6bbe with SMTP id gt12-20020a170906f20c00b00a4e9e946bbemr671692ejb.34.1712308229498; Fri, 05 Apr 2024 02:10:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712308229; cv=pass; d=google.com; s=arc-20160816; b=Zf5eDaQPmSssmJzm7oczsfhatQcZfcpnj0oVCzBO/YrTywslGWk6Bmpvdq9OKLYeWd Pg33EClTIWFdQBPDOtKN/MXToXcy3g2VmgBiHjoUNxMefkVm7aOeMPjmpFPmbKV8vrbt zpyWMY049a6Oqlhf1xRLU1p0TLT5T8Dn8QoKotjbmZDqLzUfSfzp/b3MY26CyrBXwsJH 2O6KWx7iWjQFTc0YfpywkIT2lPIvT/z8Xjs9H5IRluy0KCEyrveYWPKS1HfxTqqKmTL5 RiQfMHDtrKP6gK/GixVDvsZqmCpSvDSJ981b+Gn6ISJsh6GGSPkCPK7ucdiLy444HWRp rgBw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=VeRoNF/EWKHuynHlmfs5d4fsjEQAUTE/mmqlapIGuaQ=; fh=6gh8ci6P8zW6v461hSZsn/ePDWbgJ1eE4WmQD7oNlAg=; b=rPVhupr61NVouLN0eVKoHeo6WE/rNyqBWZtZhk9aQ+IGOnZFfNuEeyD91h24EDJvBS XBzv3eYIZINX6t61FkCQmn4X3S5jhQcOaLb4Iq1Je6OMske9A9dpD/4o3v8NPqpIICuy oacTZ0stzF35Kcfik/RLdl5lCxWANwbm2+mCGoK0FVWbswT2rnaAc/X9xd/oqr9SjPSz pKNcmgnGri40o8hyYtS4yUvgnmR5zWbYKBGGu+90paxxLpcQjbOK04wmfxDbBOMA+mYI RQNh1d6XyJs2BygDYzflmQ/+vj9ej77msE3hNgyl5W2yTHrHMs8uVDBkSQTh06rbsa4h iF5w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@t-argos.ru header.s=mail header.b=UZOrdnA+; arc=pass (i=1 spf=pass spfdomain=t-argos.ru dkim=pass dkdomain=t-argos.ru dmarc=pass fromdomain=t-argos.ru); spf=pass (google.com: domain of linux-kernel+bounces-132703-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132703-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=t-argos.ru Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id kg25-20020a17090776f900b00a4e5a769cd3si514689ejc.318.2024.04.05.02.10.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 02:10:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-132703-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@t-argos.ru header.s=mail header.b=UZOrdnA+; arc=pass (i=1 spf=pass spfdomain=t-argos.ru dkim=pass dkdomain=t-argos.ru dmarc=pass fromdomain=t-argos.ru); spf=pass (google.com: domain of linux-kernel+bounces-132703-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132703-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=t-argos.ru Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 3EC471F22324 for ; Fri, 5 Apr 2024 09:10:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E45B815FCEF; Fri, 5 Apr 2024 09:10:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=t-argos.ru header.i=@t-argos.ru header.b="UZOrdnA+" Received: from mx1.t-argos.ru (mx1.t-argos.ru [109.73.34.58]) (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 7958C15FA95; Fri, 5 Apr 2024 09:10:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=109.73.34.58 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308218; cv=none; b=cqJweNwxCH5IXQuJwVVOQTy4dAjcg0SZhuShK1KOuja8lePKv3liCsJhO5sdMRUjQo0LGmdGHA3EYl/VlMBOQrWmCn9YKq4tUSPyapJmDe1qnu35/1uTlZV3J6s0dJDgm+3iDFeOnXn7HFsbJBuXWroRRS/7Bjk++0yW7pS3bk0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712308218; c=relaxed/simple; bh=6zgWN/Gm2MnsvJelWP4xZxfUiEvn8aa8s91l1UYyo+k=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=OKHNgdR68pQMoBMRud1k7RoGuYUQ4QXlqfdMb0iWkdL7Wd9Lbns4Q/W472tWd1+CAFk2X0piECLfWUJ4ILnlmEONvCIaTPwzWrf9N+hEseteLvWrXQqI8xW7kdf/shf82ETRXAkN9Wqo98Beg6grRkpx0gz9GsYTqC9kxDp0NOM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=t-argos.ru; spf=pass smtp.mailfrom=t-argos.ru; dkim=pass (2048-bit key) header.d=t-argos.ru header.i=@t-argos.ru header.b=UZOrdnA+; arc=none smtp.client-ip=109.73.34.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=t-argos.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=t-argos.ru Received: from mx1.t-argos.ru (localhost [127.0.0.1]) by mx1.t-argos.ru (Postfix) with ESMTP id 19A01100002; Fri, 5 Apr 2024 12:09:48 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=t-argos.ru; s=mail; t=1712308188; bh=VeRoNF/EWKHuynHlmfs5d4fsjEQAUTE/mmqlapIGuaQ=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=UZOrdnA+lc/svGM+U6EefY3kFyXEWa31+mAu3vpxm3h+mpw3sutFU9OF3ifrKCIlB bxNNKunHV71q45tKYaL329KXMXwpLmyEGfENz5y34Gvi7KMklaDq9TX7rL8SDgpm1O lF/YvNb6kQGWIMZbXyia2rEWUn6SiNhP/gQLna+gcaHsyv5ZQovIFszGRM2xbr3PnH G/4H1zDv98/Hal3tgsqIrVUBoPKDGpDeGPJjAt8HMzllILIGoc8SgZfdEavqUV96FT 1shD1wxrc1mJ0h1o5Cv4cl2Bdm9XnHOYPP9/w8VjNZmepPCZuf9n+y4ms4N/j3iGF3 Qsqzq+ZrDv39A== Received: from mx1.t-argos.ru.ru (ta-mail-02.ta.t-argos.ru [172.17.13.212]) by mx1.t-argos.ru (Postfix) with ESMTP; Fri, 5 Apr 2024 12:07:47 +0300 (MSK) Received: from localhost.localdomain (172.17.215.6) by ta-mail-02 (172.17.13.212) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Fri, 5 Apr 2024 12:07:27 +0300 From: Aleksandr Mishin To: Christian Marangi CC: Aleksandr Mishin , Amit Kucheria , Thara Gopinath , Bjorn Andersson , Konrad Dybcio , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , , , , Subject: [PATCH] drivers: thermal: tsens: Fix null pointer dereference Date: Fri, 5 Apr 2024 12:07:20 +0300 Message-ID: <20240405090720.16419-1-amishin@t-argos.ru> X-Mailer: git-send-email 2.30.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: ta-mail-02.ta.t-argos.ru (172.17.13.212) To ta-mail-02 (172.17.13.212) X-KSMG-Rule-ID: 1 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184598 [Apr 05 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 X-KSMG-AntiSpam-Envelope-From: amishin@t-argos.ru X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 15 0.3.15 adb41f89e2951eb37b279104a7abb8e79494a5e7, {Tracking_from_domain_doesnt_match_to}, mx1.t-argos.ru.ru:7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;t-argos.ru:7.1.1;127.0.0.199:7.1.2, FromAlignment: s X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean, bases: 2024/04/05 06:54:00 X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2024/04/05 07:02:00 #24662400 X-KSMG-AntiVirus-Status: Clean, skipped compute_intercept_slope() is called from calibrate_8960() (in tsens-8960.c) as compute_intercept_slope(priv, p1, NULL, ONE_PT_CALIB) which lead to null pointer dereference (if DEBUG or DYNAMIC_DEBUG set). Fix this bug by adding null pointer check. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: dfc1193d4dbd ("thermal/drivers/tsens: Replace custom 8960 apis with generic apis") Signed-off-by: Aleksandr Mishin --- drivers/thermal/qcom/tsens.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index 6d7c16ccb44d..f7dd70e8d158 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -262,9 +262,10 @@ void compute_intercept_slope(struct tsens_priv *priv, u32 *p1, int num, den; for (i = 0; i < priv->num_sensors; i++) { - dev_dbg(priv->dev, - "%s: sensor%d - data_point1:%#x data_point2:%#x\n", - __func__, i, p1[i], p2[i]); + if (p1 && p2) + dev_dbg(priv->dev, + "%s: sensor%d - data_point1:%#x data_point2:%#x\n", + __func__, i, p1[i], p2[i]); if (!priv->sensor[i].slope) priv->sensor[i].slope = SLOPE_DEFAULT; -- 2.30.2