Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp969729rwl; Wed, 29 Mar 2023 10:45:08 -0700 (PDT) X-Google-Smtp-Source: AKy350bFXpWYgeKCPKWB2FeeoTD1jVZihn560n6cn2o3OCEwB8S9qkZd83pQ2W04MlZTkkiDrb+8 X-Received: by 2002:a17:907:a4c4:b0:93f:8223:221b with SMTP id vq4-20020a170907a4c400b0093f8223221bmr18103584ejc.66.1680111908471; Wed, 29 Mar 2023 10:45:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680111908; cv=none; d=google.com; s=arc-20160816; b=ablIVs9h+VK+c5hnwb/4b5hbA0tnjnc1+Rv9vFz7hfeBrNsddEFZfNxt2Y3+nd1Spj qrb/QBeCw3jGqf9znzuFMxtWnuUCv+jFOshMwg0r9hAvXIfJGnQs9+UTMCzLKl8BaKnn bEt1TuJYG7vCC8uBvTbqlDbq15XzAHDr6QqFg6BbX1FmojyRV2g0XIOG8lx65+JSQ69J t4MpxTh4ZxMwM8KWuhwwvWOWlnPQXPJj8m+Qc/Bbu5sdYlWIItrDXfYX7NLfPHtTZMDJ 7DtKe16HKeOdxBIhcSmztYr/3i/IEcHrNs8IDqzubNhYqRMt9tpICcl49o1GxElF5oyt KGMA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=G1uLPbRJeNCIOJPee8sfCyfzJt6wD6K2izLfmbNdjgs=; b=DlLsYbQZxYeDTjrT/jLzdZuvE80cgAl4o4Zcy8MLc6cnh4/owQus7pYBMYyrYItjZm RlwIE2ph+HL1t+JLy1PPRSnXtL0WqQTyGbClJQbRGl3uibiRiyomxK5ZEoaElPmTA9wJ zYDvoZd8GfentmG/DLCNoyRc/8PH7o8HJyJCl7znOy72Y1XegCCq6eW/aK+AZLphYSXf WQJpNQauTjyuAu5dv7ET8W+FOfopA2imXKTJs4qeR8W1utpH7s+oJ46DmYwRuaQ5z5Cy hLILquq6HzdHkFcszyllcHA9Nd7ksoDmSQ1wU2YJiHKAKRQi5S3y/fDn/Ezg+mpHjJYG YF3w== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qw41-20020a1709066a2900b009351546e521si14527181ejc.706.2023.03.29.10.44.42; Wed, 29 Mar 2023 10:45:08 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229668AbjC2Rnj convert rfc822-to-8bit (ORCPT + 99 others); Wed, 29 Mar 2023 13:43:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbjC2Rni (ORCPT ); Wed, 29 Mar 2023 13:43:38 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2760B5254; Wed, 29 Mar 2023 10:43:36 -0700 (PDT) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.1.0) id aafa1b008520eda2; Wed, 29 Mar 2023 19:43:35 +0200 Received: from kreacher.localnet (unknown [213.134.183.20]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 859211FA13B8; Wed, 29 Mar 2023 19:43:34 +0200 (CEST) From: "Rafael J. Wysocki" To: Daniel Lezcano Cc: "Rafael J. Wysocki" , Zhang Rui , linux-pm@vger.kernel.org, rafael.j.wysocki@intel.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH -next] thermal/drivers/thermal_hwmon: Fix a kernel NULL pointer dereference Date: Wed, 29 Mar 2023 19:43:33 +0200 Message-ID: <12190090.O9o76ZdvQC@kreacher> In-Reply-To: <5b084360-898b-aad0-0b8e-33acc585d71d@linaro.org> References: <20230329090055.7537-1-rui.zhang@intel.com> <5b084360-898b-aad0-0b8e-33acc585d71d@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 213.134.183.20 X-CLIENT-HOSTNAME: 213.134.183.20 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrvdehiedguddujecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthhqredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpeekieelheffleefgffgtdejvdektedtjeefveeugeefvdfhgfduueetiefgieelteenucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecukfhppedvudefrddufeegrddukeefrddvtdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvudefrddufeegrddukeefrddvtddphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepiedprhgtphhtthhopegurghnihgvlhdrlhgviigtrghnoheslhhinhgrrhhordhorhhgpdhrtghpthhtoheprhgrfhgrvghlsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehruhhirdiihhgrnhhgsehinhhtvghlrdgtohhmpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhg pdhrtghpthhtoheprhgrfhgrvghlrdhjrdifhihsohgtkhhisehinhhtvghlrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhg X-DCC--Metrics: v370.home.net.pl 1024; Body=6 Fuz1=6 Fuz2=6 X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS 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 On Wednesday, March 29, 2023 6:18:31 PM CEST Daniel Lezcano wrote: > On 29/03/2023 18:03, Rafael J. Wysocki wrote: > > On Wed, Mar 29, 2023 at 5:59 PM Daniel Lezcano > > wrote: > >> > >> On 29/03/2023 16:38, Rafael J. Wysocki wrote: > >>> On Wed, Mar 29, 2023 at 4:16 PM Daniel Lezcano > >>> wrote: > >>>> > >>>> On 29/03/2023 14:06, Rafael J. Wysocki wrote: > >>>>> On Wed, Mar 29, 2023 at 11:57 AM 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. > >>>>> > >>>>> So maybe instead of the wholesale switch to using "driver-specific" > >>>>> device pointers for printing messages, something like > >>>>> thermal_zone_debug/info/warn/error() taking a thermal zone pointer as > >>>>> the first argument can be defined? > >>>>> > >>>>> At least this particular bug could be avoided this way. > >>>> > >>>> Actually we previously said the thermal_hwmon can be considered as part > >>>> of the thermal core code, so we can keep using tz->device. > >>>> > >>>> I'll drop this change from the series. > >>> > >>> But it's there in my thermal branch already. > >>> > >>> Do you want to revert the thermal_hwmon.c part of commit dec07d399cc8? > >> > >> Oh, right. Fair enough. > >> > >> I think Rui's patch is fine then. > > > > I guess you mean the $subject one, that is: > > > > https://patchwork.kernel.org/project/linux-pm/patch/20230329090055.7537-1-rui.zhang@intel.com > > Correct > > > What about the message printed when temp is NULL. Should the original > > form of it be restored too? > > Yes, you are right, for the sake of consistency we should restore also > this one. So I'm going to apply the appended patch. Please let me know if there are any concerns regarding it. --- From: Rafael J. Wysocki Subject: [PATCH] thermal: thermal_hwmon: Revert recent message adjustment For the sake of consistency, revert the second part of the thermal_hwmon.c hunk from commit dec07d399cc8 ("thermal: Don't use 'device' internal thermal zone structure field") after the first part of it has been reverted. Link: https://lore.kernel.org/linux-pm/5b084360-898b-aad0-0b8e-33acc585d71d@linaro.org Signed-off-by: Rafael J. Wysocki --- drivers/thermal/thermal_hwmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: linux-pm/drivers/thermal/thermal_hwmon.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_hwmon.c +++ linux-pm/drivers/thermal/thermal_hwmon.c @@ -236,7 +236,7 @@ void thermal_remove_hwmon_sysfs(struct t temp = thermal_hwmon_lookup_temp(hwmon, tz); if (unlikely(!temp)) { /* Should never happen... */ - dev_dbg(hwmon->device, "temperature input lookup failed!\n"); + dev_dbg(&tz->device, "temperature input lookup failed!\n"); return; }