Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp656521rwl; Wed, 29 Mar 2023 06:58:34 -0700 (PDT) X-Google-Smtp-Source: AK7set911lyaDaq11e2FMb9Mqb5o48LcET8mZiHUVcC3WXPhhP9AjlG5OjcNpVaId4j+i2rJPhtT X-Received: by 2002:a05:6a20:cc59:b0:db:9a60:a52d with SMTP id hq25-20020a056a20cc5900b000db9a60a52dmr14160440pzb.41.1680098314032; Wed, 29 Mar 2023 06:58:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680098314; cv=none; d=google.com; s=arc-20160816; b=CJLYNztNMy6bA/1DrloEHL3d3CRqRLO5S/8w6MJ2avXlh/8HQSrKnl2cuSemTNecop osFWQPV9ZK+MRKOoa9YjGfwypWN8G5m2zOrLdEgpb8iZeLV4t0l+lB5w5oLDHXjgw9rH W71rELuz3E/DlpLitOiUshxjKhsULfeHr0kiw4j2c68jMPd4aZhYMCOag/9anKTiwnw5 6eOioK6fozyG7lwwcMoOZf6wMLd+9qFM5Hxc5klCi69VIQzGQ2zJ+8nCm6TRPdFRd4yT hxEz4Ryfa95jNtNHNtz5nsNCO13SOrtZjiXTyrHLNsiTTWM2wuCdgV5a0p69jnkFeoIF 9Thg== 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=yaE6C1xMETts3FrE+eHvp8fbHac4JNfCSyQOVnxvW+Y=; b=h4xC7I+EESOJZftew5VpNWVFeV7oGkn5T800ITS8xpnkSsq4KX/6tshqRZI9talaiO P0aFASRGc+PdgBJlAa60gSXNM8w2p6gmrLCpRR2AriVUXfz3Bvu5ow3fvnPJTkZB0rB1 gD75SBbsZ/PY2XGplHEi/3HxopHPCKO+CYNw/Pol8QGE8UObA4xSP5yEOtu9Auag1C6i a1wSLFy6F1FJO7GF0NjSueXEWKF7Dv1/6IbWdP+Ad0o0MFVgQ+JzuW3yzO3GUABaCt3s LCxCl3Vc3A9o64h2tygizBQet9gfu/WTzQ+YZBOFrib1hzrrVQfg0+qkM8gp4hsB3FYz 2gMA== 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 j71-20020a63804a000000b004fb95c8f647si1680917pgd.407.2023.03.29.06.58.21; Wed, 29 Mar 2023 06:58:34 -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 S230316AbjC2N5k convert rfc822-to-8bit (ORCPT + 99 others); Wed, 29 Mar 2023 09:57:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230357AbjC2N5e (ORCPT ); Wed, 29 Mar 2023 09:57:34 -0400 Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D68A3C4; Wed, 29 Mar 2023 06:57:33 -0700 (PDT) Received: by mail-ed1-f46.google.com with SMTP id h8so63678727ede.8; Wed, 29 Mar 2023 06:57:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680098252; 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=pZTShwYbvOvjgqDDpP3UxaUPOYmei9lppEGt3H4hS50=; b=wCamshZQFmYD9AYrFd3+Jte7qivmL52aHul/DDLBroeQ2zn8Ynje5IV5DlBssvFrdq uTmtChGeGUnDhY0yppHDoiApZghfr/RgczxB7QCXIaKfr1+gWJv4RC0HlheFez5G1zUS TY12faC2Jxf4EIuaoX7zZcJhMvRtFLWwkkRjGlrmPAuonJGrxEy9SZNZVdveK4GK2mea dPJjd4rQ08QBuF+88qh2Bq9vE1xt1M25/E9GcthO6Af+6FoYpmwtpk9d2kxjZQK/UFRp NnaW3vUz8F5hbZbT2kqeqeIyZ5JV4n8Jv35LxacHI20JSw8EdDJ/0KddGHC8MxAKqGXk Drfg== X-Gm-Message-State: AAQBX9d+lMI/xvmFfqr0Vdjt4LtCgZZk/rUacJogwAZnh8WSwB9l/jHZ eJ8C2te0fAHtFjYgwhOpqyEfXa0EWzdoqR9HcPjPeG0n X-Received: by 2002:a17:907:d48d:b0:93e:c1ab:ae67 with SMTP id vj13-20020a170907d48d00b0093ec1abae67mr8849591ejc.2.1680098252316; Wed, 29 Mar 2023 06:57:32 -0700 (PDT) MIME-Version: 1.0 References: <20230329122629.3614-1-rui.zhang@intel.com> In-Reply-To: <20230329122629.3614-1-rui.zhang@intel.com> From: "Rafael J. Wysocki" Date: Wed, 29 Mar 2023 15:57:21 +0200 Message-ID: Subject: Re: [PATCH v2 -next] thermal/drivers/thermal_hwmon: Fix a kernel NULL pointer dereference To: Zhang Rui Cc: linux-pm@vger.kernel.org, rafael.j.wysocki@intel.com, 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 2:26 PM 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. > > 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 Do you have a link to the bug report? I'm wondering where exactly it triggers. > Signed-off-by: Zhang Rui > --- > 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; > } > > --