From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09D1CC74A5B for ; Wed, 29 Mar 2023 16:19:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229486AbjC2QTI (ORCPT ); Wed, 29 Mar 2023 12:19:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229917AbjC2QTA (ORCPT ); Wed, 29 Mar 2023 12:19:00 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1378C26A4 for ; Wed, 29 Mar 2023 09:18:35 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id i5-20020a05600c354500b003edd24054e0so11830395wmq.4 for ; Wed, 29 Mar 2023 09:18:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680106713; 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=U/3ZXVoIKxVs/p2ePsaiOudqZVjYFCyOHTolPsKeMIE=; b=zhBeRzLjXXN7jqHGC5Zw1MCquTnjs3lNKA492yHvqv0SUf7DJk+Tnys0BFYYF2YGAW yUw+JIaXTFsSCqebewTBv4ccDWzd+b8a1dy9I3wcnlN8oQx/7t1b//sWMXV5sR8l5LE+ sLQiyvWhw8EwtSFoAR3IBGHWd5kSohsAKhLcknR4BTxhUGma3FVv6JpS/d0Rq6r4O63S L9viX+3tSrw71RNxR02c/BnChgQAJUCub/+VjrcwJcHYNRwF5GjJ82mTe5rdQkF7nGfN h/HOwKTCyGriCjbcC4cTSfpQB9olMxKXwNHZLZV8j3/k3gutSPSsI+XM34N0TbABzuYk gKXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680106713; 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=U/3ZXVoIKxVs/p2ePsaiOudqZVjYFCyOHTolPsKeMIE=; b=c8iI/E6waATp7XzeCzl+FpbFsLlXevXzdbr70U+5felldEPgrMMr2nLCSw2lo/y0qn su5fsjn7y/b1j/4HrhFYa2REGyj6/ccmYL5Hr8D8CIIc23eCZ05ufsxdyO1LCOAlHNcF Lc1l0B1LCku/A0fLgOEEtcHlGb64BS22ESaAZbDwtGYPY84S5oOyEzbvnpA2u7cLYTbV j6A5OX3LsjHp6H4orO1w5MxwndR/RyIIKhJtA0O+9EyanmIdt3qQeX1vcjze5Bx0taWy xNkXGA78XxrziPjmej0H4WMLqX528SM7TLXgy2RwORYjoPn/wEg4LlyOJnK7Q+e0rdLj Fx+w== X-Gm-Message-State: AO0yUKX0ZjmWEsb/ykmeFhS3KfgcdB6GS+6In0w5//ZqLwlwxFOao6aF U3bQmcd2dRi9gLvc0SnuS5M42lqCJeGI+LZBeqc= X-Google-Smtp-Source: AK7set+VydZ65WUhInUNI7FznI50frXNOSsSP5cK3NBVorxmB4VPsyYYoMa3LmNx8MnkEX15ayGKLA== X-Received: by 2002:a7b:c8c4:0:b0:3ed:ce6f:e86e with SMTP id f4-20020a7bc8c4000000b003edce6fe86emr15341004wml.23.1680106713524; Wed, 29 Mar 2023 09:18:33 -0700 (PDT) Received: from ?IPV6:2a05:6e02:1041:c10:7c0e:2838:74e9:d05? ([2a05:6e02:1041:c10:7c0e:2838:74e9:d05]) by smtp.googlemail.com with ESMTPSA id fc11-20020a05600c524b00b003ebff290a52sm2956826wmb.28.2023.03.29.09.18.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Mar 2023 09:18:32 -0700 (PDT) Message-ID: <5b084360-898b-aad0-0b8e-33acc585d71d@linaro.org> Date: Wed, 29 Mar 2023 18:18:31 +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: "Rafael J. Wysocki" Cc: Zhang Rui , linux-pm@vger.kernel.org, rafael.j.wysocki@intel.com, linux-kernel@vger.kernel.org References: <20230329090055.7537-1-rui.zhang@intel.com> <08aee7fe-eddc-7841-2539-16ae43fd8d66@linaro.org> <016dc073-c9a3-4b96-6c58-7b21e0f998a5@linaro.org> From: Daniel Lezcano In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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. -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog