Message ID | 20230329122629.3614-1-rui.zhang@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp380520vqo; Wed, 29 Mar 2023 05:40:32 -0700 (PDT) X-Google-Smtp-Source: AKy350bGhoWCVsNcs2+eiFK15yguwzbyvdqX5SRCV2FqHH1w1qk/iEq5IZE6092ufDTEE/EPkhR+ X-Received: by 2002:a17:906:4bd7:b0:930:3840:1c4d with SMTP id x23-20020a1709064bd700b0093038401c4dmr20283197ejv.32.1680093632218; Wed, 29 Mar 2023 05:40:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680093632; cv=none; d=google.com; s=arc-20160816; b=TavLLPeDNCoFRr2TtA3SiknF/a8XxcxiZu9MVKWcbQJqS1LjCzeeJ5SIxEMTSP/l4y J6y5C0xXigtiWPhc39CmbwkfC/19l8vTeG4qMyOwhBU4BM9rp1C+nAa+FHDElJRPaYAl RmTESJSXeLb89PCDM+Swe0IHMaw2UXAsvvBTTvmvr+eKnAd785A76cpS7r7oTHDOCdha HrgYVhY9IVHo5OJyzXnosp1hd4DST8hbeQZZDG+S4PWRfcmz5XPbcgwnBMWJrOZttavH vCk/ERo2H0TVm/DUiCP4sVnNK4CSrxJ/IdHThvWkbHbLM0ki16yrc/NMVRoOc6qBcsyY E1lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=/6blKWi+bsykOxBvkiY2qNNByJgmteD3b8kopcUUrOQ=; b=yonVuMEfOVX8N3s0c3wPJYJQyHuZcSbnI0G5ByGZpldy3e0bOT4CnOD/QpjihyKlAF lKpbPSykcID2rK4PpszkqBO041M2rXAUfRkWA7kFJ3OBOunHm23LefcYA2qa62oO+WWR 0jD2IDOisQdORphuJwbI6yhNjgVhdMrT0Vi+/3W0hbSfIek4KkkKDX8Fb6KHhUnmyOtz /T2G6q9OWwJ1cWmjxt+9eFRBx5eKXWT6sgNkC77e+lY9IK1sC4L+mPqVZqxJfmGLBQYr d69j0KTHOEucLFU8MnkMXWGcHAMdgibbSV6BQlnQh8z5dvdxdU3eIkAkZSE1Xex1oZiD bxCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Z62vlp1Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wv2-20020a170907080200b0093fe6abfa07si11112044ejb.305.2023.03.29.05.40.08; Wed, 29 Mar 2023 05:40:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Z62vlp1Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229603AbjC2M0r (ORCPT <rfc822;rua109.linux@gmail.com> + 99 others); Wed, 29 Mar 2023 08:26:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbjC2M0q (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 29 Mar 2023 08:26:46 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9A921FDB; Wed, 29 Mar 2023 05:26:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680092805; x=1711628805; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=OgXKX8f5LtCP6F/FCEPIp0Qcorekvwc2ZSrKnL0cKeY=; b=Z62vlp1Yr2LN9WrknpHw8gWZAogOrSxJMYuCBx4uoYhHoTy0t5tKvhG3 HgijylMset3TNnGhq4OFsP9clWtBRz6FvwWIu3BbYmqmSGnYKG8VDnQGh x56f2D7O8nK1C6tXoK2mQEHJLrXyn7sp6BdOdanQ84x70IV5Z62/sx1DX sp0Jh5mc1QkoNzuuEXf+C8ubpqNp5q4NL6POvsWdrIMs1k+ceuozReCu3 hQAkPgF80Q4Pv+iSHwgdkAPphtieqrcHDX1A+KciUJQjkFpEDyUPoI83f D6eQepRhhB7yNO+TeZ2zuSI2UKfxnF2MP7SMW3RvD0J3hgUVlt47+eYJ4 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10663"; a="329328841" X-IronPort-AV: E=Sophos;i="5.98,300,1673942400"; d="scan'208";a="329328841" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2023 05:26:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10663"; a="684248568" X-IronPort-AV: E=Sophos;i="5.98,300,1673942400"; d="scan'208";a="684248568" Received: from juhuangx-mobl1.ccr.corp.intel.com (HELO rzhang1-DESK.intel.com) ([10.255.30.109]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2023 05:26:43 -0700 From: Zhang Rui <rui.zhang@intel.com> To: linux-pm@vger.kernel.org, rafael.j.wysocki@intel.com, daniel.lezcano@linaro.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2 -next] thermal/drivers/thermal_hwmon: Fix a kernel NULL pointer dereference Date: Wed, 29 Mar 2023 20:26:29 +0800 Message-Id: <20230329122629.3614-1-rui.zhang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761705860328898952?= X-GMAIL-MSGID: =?utf-8?q?1761705860328898952?= |
Series |
[v2,-next] thermal/drivers/thermal_hwmon: Fix a kernel NULL pointer dereference
|
|
Commit Message
Zhang, Rui
March 29, 2023, 12:26 p.m. UTC
When the hwmon device node of a thermal zone device is not found,
using hwmon->device causes a kernel NULL pointer dereference.
Skip removing hwmon device for thermal zones without hwmon device, and
fix the kernel NULL pointer dereference when hwmon device is not found.
Fixes: dec07d399cc8 ("thermal: Don't use 'device' internal thermal zone structure field")
Reported-by: Preble Adam C <adam.c.preble@intel.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
v1 -> v2
Add check for devices without hwmon device.
Use pr_debug instead of dev_dbg.
---
drivers/thermal/thermal_hwmon.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
Comments
On Wed, Mar 29, 2023 at 2:26 PM Zhang Rui <rui.zhang@intel.com> wrote: > > When the hwmon device node of a thermal zone device is not found, > using hwmon->device causes a kernel NULL pointer dereference. > > Skip removing hwmon device for thermal zones without hwmon device, and > fix the kernel NULL pointer dereference when hwmon device is not found. > > Fixes: dec07d399cc8 ("thermal: Don't use 'device' internal thermal zone structure field") > Reported-by: Preble Adam C <adam.c.preble@intel.com> Do you have a link to the bug report? I'm wondering where exactly it triggers. > Signed-off-by: Zhang Rui <rui.zhang@intel.com> > --- > v1 -> v2 > Add check for devices without hwmon device. > Use pr_debug instead of dev_dbg. > --- > drivers/thermal/thermal_hwmon.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmon.c > index c59db17dddd6..1cdee2ee8d4d 100644 > --- a/drivers/thermal/thermal_hwmon.c > +++ b/drivers/thermal/thermal_hwmon.c > @@ -226,10 +226,12 @@ void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz) > struct thermal_hwmon_device *hwmon; > struct thermal_hwmon_temp *temp; > > + if (tz->tzp && tz->tzp->no_hwmon) > + return; > + > hwmon = thermal_hwmon_lookup_by_type(tz); > if (unlikely(!hwmon)) { > - /* Should never happen... */ > - dev_dbg(hwmon->device, "hwmon device lookup failed!\n"); > + pr_debug("hwmon device lookup failed!\n"); > return; > } > > --
diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmon.c index c59db17dddd6..1cdee2ee8d4d 100644 --- a/drivers/thermal/thermal_hwmon.c +++ b/drivers/thermal/thermal_hwmon.c @@ -226,10 +226,12 @@ void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz) struct thermal_hwmon_device *hwmon; struct thermal_hwmon_temp *temp; + if (tz->tzp && tz->tzp->no_hwmon) + return; + hwmon = thermal_hwmon_lookup_by_type(tz); if (unlikely(!hwmon)) { - /* Should never happen... */ - dev_dbg(hwmon->device, "hwmon device lookup failed!\n"); + pr_debug("hwmon device lookup failed!\n"); return; }