Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp367948rwl; Wed, 29 Mar 2023 03:06:55 -0700 (PDT) X-Google-Smtp-Source: AKy350bDvTAhI2lOPeGVsM7uymYSMiP/leRwLBO7ORBFVMM+Ta59HvTS1BFWwP7v1AukJQKkpY8t X-Received: by 2002:a17:906:a04b:b0:93e:2a40:316f with SMTP id bg11-20020a170906a04b00b0093e2a40316fmr1698738ejb.28.1680084415652; Wed, 29 Mar 2023 03:06:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680084415; cv=none; d=google.com; s=arc-20160816; b=B9J/GXM6WXG0GeAIo0CyAukulpov0wDPGjdenELWqXttps03K586bDWMq2LaU1orCf NdhNdg+gwjorxpIdtyszq2Gm0GHplKR0h9WNSZB+s3jvdu8AhGdLlDF7kfh6y2zjTl+f C/8uKTw8Ddnz5aHiUSsE16ZtdWM8qHGeVOFPLxG+Y25qFdXWAPs1pooV3nxv2pt8T+U0 uI4s1g03hP7LdlRqsfkSnGqp1jLaNvU9OrCswF6TdXKBeTkV5HYujQW7E8Sidem9m2c3 MLL00dnaEdKZExD5mTspsTiHUDrIFDnnPNZcqnFAlr4iMHaAYLp+EfnKL+yYI0nH5glA LueQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=FpDwgmB/u9vyHkL9sWwGB0UNeE/S7UThI/HZB1NgANU=; b=YWOS7FWsG5BIuPXKSzv+GmA0PJaNn+hFMLLwy//CJ5RCsO1QCFSs6OcG2sreIvaZh6 +YVkLTS3Ki8wjxve+pS9Sunt05QLTFRyp3hBOQK09wdTNqmI1b2aKttnjbcXCa3n38MX byKPRXyRjemw+5QjFludfQVYD92Ve0PtVDVVeiG7vZw87gFnfpOiGZ3oEHJNqURSF+WJ NF9fA/K1kgtIUpKyfNFplRb9gFppleTMBWOZnN+ELuSQKecREM0pVY/gJDolaQvVUH+X klnCD/UtzCkzkLt98AETdZvBroBxsan2wI53n24U60ZohlKpv2oQNCozM5FnmUIsKw8W lVJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fz4NvHv1; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pj15-20020a170906d78f00b00939c395018esi20121845ejb.474.2023.03.29.03.06.30; Wed, 29 Mar 2023 03:06:55 -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=@linaro.org header.s=google header.b=fz4NvHv1; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231379AbjC2J5o (ORCPT + 99 others); Wed, 29 Mar 2023 05:57:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231421AbjC2J5h (ORCPT ); Wed, 29 Mar 2023 05:57:37 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D186E1BC8 for ; Wed, 29 Mar 2023 02:57:34 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id l12so15004763wrm.10 for ; Wed, 29 Mar 2023 02:57:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680083853; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=FpDwgmB/u9vyHkL9sWwGB0UNeE/S7UThI/HZB1NgANU=; b=fz4NvHv1EzsirLqLhPN2yCBBo7zPz9i6igQXeykMIbVXnmacbZlaVloT9oExv6leb2 //O9TTeUtlAcEi9YOGiUO3/IKFI6n/ImQdMBUy77kopI2pW4hA3DTqocZIZNRqG4mzAC IkSn2Qu8uUpa7/oGGpw7JCuTerPTVqHH9ZeZP+yutTSp1Od9ZCmfqm+d4OrFN4R3Pdcy ptogcAi11EP4LUGscAowEn5PZ7qGgFRyKRuuYo3zIaiGABts42vkFzwQkWgk/e5ta4y7 WRv3D2hsICB3Ur4m0Ra7SchroZ+C5uiBoo1uHFaapTZGPcmhLQt+FjLThZRbvd1bamI2 zw3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680083853; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FpDwgmB/u9vyHkL9sWwGB0UNeE/S7UThI/HZB1NgANU=; b=yNx/UU7ykkGUuxcD64P6rdrmb95C1HiS6Usei+QT0KV/RVyy3PSm/nQldwCHWO18Hz sxtdky4lt2ZUHKqeIeia3z/mRFYMQ/7ws94b0VH6zS4F0USwRqD7jkksdRL5ZMXgnG/p gLMxgJ281NgWUJ+D6zhs8wkuGlK5pYWqCVSMaurEH4dlX2FM9K6nvPjkiFpoLE792yTy 7uzSCyw421pEWNxFXrVJPWa/yKSlZRVnJFBpzeqMhzqyb8Wo8jOs5v63bjCqu7NhZsR0 cnsCggbmla0SE0Y4DJvvfQdlbONk3WSo0UIOhWCU2RAjdxJwWn0jq4aEZutqN5yznl5K nOkA== X-Gm-Message-State: AAQBX9fyBK354ErXxWQYX/Pey9tDOUTPfIlW28M4ehLQ59rIjQ42UEWu K/VbtadyFX7QuINhKWQlqZFBsg== X-Received: by 2002:a5d:590c:0:b0:2c7:d7c:7d7 with SMTP id v12-20020a5d590c000000b002c70d7c07d7mr1164710wrd.22.1680083853278; Wed, 29 Mar 2023 02:57:33 -0700 (PDT) Received: from ?IPV6:2a05:6e02:1041:c10:8f24:e6f1:ea42:cf21? ([2a05:6e02:1041:c10:8f24:e6f1:ea42:cf21]) by smtp.googlemail.com with ESMTPSA id i1-20020a5d6301000000b002d9568395f8sm19705034wru.36.2023.03.29.02.57.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Mar 2023 02:57:32 -0700 (PDT) Message-ID: <08aee7fe-eddc-7841-2539-16ae43fd8d66@linaro.org> Date: Wed, 29 Mar 2023 11:57:32 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH -next] thermal/drivers/thermal_hwmon: Fix a kernel NULL pointer dereference Content-Language: en-US To: Zhang Rui , linux-pm@vger.kernel.org, rafael.j.wysocki@intel.com Cc: linux-kernel@vger.kernel.org References: <20230329090055.7537-1-rui.zhang@intel.com> From: Daniel Lezcano In-Reply-To: <20230329090055.7537-1-rui.zhang@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, 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 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; > return; > } > -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog