Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp502170rwl; Wed, 29 Mar 2023 05:08:14 -0700 (PDT) X-Google-Smtp-Source: AKy350Z8LsyoKUMLTvP3ewMVsyszJg4Z+4tRHr85Q1ab6c7fwBPLqak5CaBr7SfOz9h0lLqAgc9T X-Received: by 2002:a62:3846:0:b0:623:8592:75c4 with SMTP id f67-20020a623846000000b00623859275c4mr18087453pfa.29.1680091694349; Wed, 29 Mar 2023 05:08:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680091694; cv=none; d=google.com; s=arc-20160816; b=O03s33HMpz1bOPoZeQhTf+mGVXiMdXAm8YKMghqOVXRiGG8Gw3rXf1FIE90ND+B1k4 hxoj4mZ7KOEWK5MOFPseGDRHnA9Y9XmRKxI5Ie+XHUFSsLGSqvPJO4Jz1blcFAO4vUST bTXAbztO/4bYnHaR7ME5l/wpoBS6D3GLyxioZl8FqzwFnKDevihRBx+3muSB9O/ShvHq jpbCZbzKwI09VR4yaUtzQzJ93fZJhKU46zc+9umWOOU2766LC2F7QSxAFWMz8YqXu6Pe yNHHmV42Cpsbr2ATF6n3zYUBq8FqkYxShD2fBE/tRDHC9IDb8iLFlysfaNiJQUiLqdgn hWvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=C5OLvo5OU619FDxlQs+wKjml/xlkfr5dY8TvbfTDooo=; b=GbJFdpxrVEw1eZxnunkBEQ/spNRQb89Y9YFVprEhhERDasxKbGxSgt5H8smNq6ctdF n+iopn2e2M9NPBbJw0TmsZ9+T9ldPamlGvnRgLsfb4ILU4nWWcSZDE6/1UgOgbuomMEJ R2UE8nsbENZSzGNhE1gkIMhqYK3uPh/UFT/1wOzG0tHk9pwQBWZ7SwRHn3X1V7Cfpc9n q+MtJN+JGzIarnsYh/TL01GjewIZJMzxIV7wcKMvwAj/zJG8fY4JLacNDb3l844c6Ucs imtU13DXYhDmukzF8IP1heVtmsP3HJKO9xTpTkXAyOITm8T1Ee2Evll66/hk2plzJ/xC lb1Q== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x184-20020a6286c1000000b005a8ec89de5fsi30892764pfd.236.2023.03.29.05.07.58; Wed, 29 Mar 2023 05:08:14 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229819AbjC2MBV convert rfc822-to-8bit (ORCPT + 99 others); Wed, 29 Mar 2023 08:01:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbjC2MBU (ORCPT ); Wed, 29 Mar 2023 08:01:20 -0400 Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97AB5EA; Wed, 29 Mar 2023 05:01:19 -0700 (PDT) Received: by mail-ed1-f42.google.com with SMTP id b20so62235563edd.1; Wed, 29 Mar 2023 05:01:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680091278; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YiCrbsp6PX3orS6Usf/w3A1cmbB/1aAzcIibJJyJkDQ=; b=qRYRdWofSOWykGGhZRvyeMI2s/bd3eilTUqI72OjJmjeTSKC6e3G871vTM1UnZnznz +OcWMmzwErKGvxEP263qMlo7p/f9P7ZwyBsmeHlxFDX8/CyOZbvmzHY1srajsZe/AbZ5 iG0KIH/w4CfcdpUfCNHjtfxfBwi27eIO+z4IFHyTfVK94FWq87JtRcKnxG8R310DkgwL HM01v8ko/ZKGM3VhLo2btr9MR7EcpfBU8ICKRs/E1niJdpJlNluktwAraxQ5YvaeFMqk 482taYql/fId7StrUnu0p05GvXCvnnCPeE/jWFa7UwlzFPKL7fyS57oZZFJm2ILXa47H OZQw== X-Gm-Message-State: AAQBX9crRATsAKnegWSiFBoIDWb4IbfxGViqiRQ4xLYHEbktMQgisne4 70I95l0ylMVG0D7fO0UO3O/3twj9nbohpQnOSaQ= X-Received: by 2002:a17:906:5fca:b0:930:310:abcf with SMTP id k10-20020a1709065fca00b009300310abcfmr9625484ejv.2.1680091277922; Wed, 29 Mar 2023 05:01:17 -0700 (PDT) MIME-Version: 1.0 References: <20230329090055.7537-1-rui.zhang@intel.com> <08aee7fe-eddc-7841-2539-16ae43fd8d66@linaro.org> <794b4b0eb6a0181b5e01f17e720a56e5ffaaf2e9.camel@intel.com> In-Reply-To: <794b4b0eb6a0181b5e01f17e720a56e5ffaaf2e9.camel@intel.com> From: "Rafael J. Wysocki" Date: Wed, 29 Mar 2023 14:01:06 +0200 Message-ID: Subject: Re: [PATCH -next] thermal/drivers/thermal_hwmon: Fix a kernel NULL pointer dereference To: "Zhang, Rui" Cc: "linux-pm@vger.kernel.org" , "Wysocki, Rafael J" , "daniel.lezcano@linaro.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=0.5 required=5.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no 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 On Wed, Mar 29, 2023 at 1:24 PM Zhang, Rui wrote: > > On Wed, 2023-03-29 at 11:57 +0200, Daniel Lezcano wrote: > > On 29/03/2023 11:00, Zhang Rui wrote: > > > 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. > > > > Actually it reverts the work done to encapsulate the thermal zone > > device > > structure. > > > > > --- > > > 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"); > > > > As it 'Should never happen', I would replace that by: > > > > if (WARN_ON(!hwmon)) > > /* Should never happen... */ > > return; > > Actually, the comment is wrong. > > For thermal zones with tzp->no_hwmon set, this is always true. > > We should add an extra check for that. OK, can you please send a patch fixing all this mess?