Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp310213rwl; Wed, 29 Mar 2023 02:03:03 -0700 (PDT) X-Google-Smtp-Source: AKy350akHiq5LC2bLLjXTLWsn/gZ32iQnGNYshVqmG/hsvOhidMLCojXeBs+ec56HSJU8iJGd6MS X-Received: by 2002:a62:5254:0:b0:5cd:d766:8a2b with SMTP id g81-20020a625254000000b005cdd7668a2bmr16242986pfb.6.1680080583676; Wed, 29 Mar 2023 02:03:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680080583; cv=none; d=google.com; s=arc-20160816; b=BseoYqP4vTZ7PseQ84vf2NM33Esyq2Jav2c/BQ5zUpGGxSZzRXM13KExCgixD6pb7g qJafrjiFHo9DWvQQ4NdGgFBsXC/QB94aY35Mzrf6I2DaIP3TnlTEHaMzU+2QWX5zTXBp W9bRRWs41SEbljuRlcpnzQrnzvfTUzCO/GdcRjDEHn2oa7W+y+J8UDgwtJTLc0yiaY4I /coRDL+qGNt4bXhdDet1s8kIrj8MQ7sFKTSCJLcW1WiedY8XZvWv/i+0hUyfEOY9yDmW 9G4+t592Q7ABPOaz0nWxlHjp4x4SIpbNdFCqaUQCIk9M9Ic1WyjaZ1ZbMeRZYxdZ53uG bn2A== 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=/em/cTbH5xFNgT5F0G1wwB8OubHKzw0ZFET6cLvYbI4=; b=b1utmNvGraOeR3KlX85pNemUUwsnvLgcuqfsnW8Dx2BMxfMK0jIA6zu2CJ41zJs5Vi Pfb1s5ffz2h1GdgEV8h0ag7yvBqGeebbENAe39QO5yLmwwn5DfARPyV73FZbjzr9VT2n CN7DTTCYQhEbNMlKiwEnee+Hr9Imo0F1aOUVejpMJVNJDzwwX0ZIdKSyVM6zeAc20e6B Jk1PhCOmrlZTOCirwhKgujv/noIFYUXPlZCaOtU7PUTnpDLuXvKrl08QPzWccaIXbaHE wmZKD7je9vv6/gby+W2QNLvwqj/8ikhSiaujQ1W7/FMgEXMstpHGfKUe2P2VxW2a2wCo eQUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VJvlDSum; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q3-20020a056a00088300b005dd4ab3a2c3si15433279pfj.182.2023.03.29.02.02.51; Wed, 29 Mar 2023 02:03:03 -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=VJvlDSum; 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 S230072AbjC2JCZ (ORCPT + 99 others); Wed, 29 Mar 2023 05:02:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbjC2JCV (ORCPT ); Wed, 29 Mar 2023 05:02:21 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46DD549C7; Wed, 29 Mar 2023 02:01:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680080509; x=1711616509; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=MpN+NoE8ltrbIOFRhoiH8RX1fmB1SfinxkoJtqy1yZQ=; b=VJvlDSumZvChIuQE72fkllLEKkkOVJkHZLdhTmR128bZ978zpCRHRUyR Msklf7Co3nNoy1WWs+vUuceDB9ocfnyPvIXwopKtPtnCKZ9gvSs5yKTiN E3awsYZ5bx5dRAImEgwl8t7ydZxjq8tJDOGAFFZzp4drQUpBotH7bSstQ u4g+oYUsXKrF3lEyAHHdwuQoqkRlcoJVKK+4bkXUbzDbzBnFljn7o2xyD Pw5ZIrZtfLfnBTIQagYLuQEN7KvSDQ6v9uC/tEOX7DC3fRV/mUdXoIMLf YeytPmGqGHRCbOZXZ0KeAJmhk0yniAf7ddqIY8qnOqG94BfM04uLcaVts Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10663"; a="324726927" X-IronPort-AV: E=Sophos;i="5.98,300,1673942400"; d="scan'208";a="324726927" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2023 02:01:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10663"; a="748717768" X-IronPort-AV: E=Sophos;i="5.98,300,1673942400"; d="scan'208";a="748717768" Received: from wenqin8x-mobl1.ccr.corp.intel.com (HELO rzhang1-DESK.intel.com) ([10.254.212.141]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2023 02:01:03 -0700 From: Zhang Rui To: linux-pm@vger.kernel.org, rafael.j.wysocki@intel.com, daniel.lezcano@linaro.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH -next] thermal/drivers/thermal_hwmon: Fix a kernel NULL pointer dereference Date: Wed, 29 Mar 2023 17:00:55 +0800 Message-Id: <20230329090055.7537-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=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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: X-Mailing-List: linux-kernel@vger.kernel.org When the hwmon device node of a thermal zone device is not found, using hwmon->device causes a kernel NULL pointer dereference. Reported-by: Preble Adam C Signed-off-by: Zhang Rui --- Fixes: dec07d399cc8 ("thermal: Don't use 'device' internal thermal zone structure field") dec07d399cc8 is a commit in the linux-next branch of linux-pm repo. I'm not sure if the Fix tag applies to such commit or not. --- drivers/thermal/thermal_hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmon.c index c59db17dddd6..261743f461be 100644 --- a/drivers/thermal/thermal_hwmon.c +++ b/drivers/thermal/thermal_hwmon.c @@ -229,7 +229,7 @@ void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz) hwmon = thermal_hwmon_lookup_by_type(tz); if (unlikely(!hwmon)) { /* Should never happen... */ - dev_dbg(hwmon->device, "hwmon device lookup failed!\n"); + dev_dbg(&tz->device, "hwmon device lookup failed!\n"); return; } -- 2.25.1