From patchwork Wed Oct 19 08:24:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4724 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp213996wrs; Wed, 19 Oct 2022 02:11:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM73PkUgjAbr2uXOEPQMAr6yf2vCy3QXIvVdoDBp/UVINRxKhdcy0khc8xlCQcjBL0AC1VV3 X-Received: by 2002:a17:907:94d6:b0:78d:f947:7cf5 with SMTP id dn22-20020a17090794d600b0078df9477cf5mr5926489ejc.446.1666170699220; Wed, 19 Oct 2022 02:11:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666170699; cv=none; d=google.com; s=arc-20160816; b=PepC3s9f6EZhrgO1XgzoAJO3Lbx2oyS7BNuKJJC7xPl+CcOaIfvg4Ynyo4XbOJ/Mfj CxsFB7/pVuUGNVxm3nf1FWiBZEGfDftksgzckrzcyMVU4mOoGFzXqjfn+8VOuIdVUwfp qCzBggqxR/3znpFjFOQORqbJZtkf6WZCPGk/rZgh1KmBsNqvbudnNp84NAc0pQN7i1P2 a7281NNv6Nj/gd5fG/im4RClswsxTiYStWTPkOZV5uKd1cN/DrG6ONYDYKYPQCWDiokV I5ZoZFGRSkNG4opsOTdMnG2GmnyhJqfdfvT9/YxE9CVtvC5EM8BUOKuUxEixQo4naNg1 hmNw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=moFSFN+3NJMC1JHo04xbo5gs+eGllD0E/R1sHL4iETA=; b=ljWaUBP3unxXVDcFRB9zxzJ6oJDmcGTUvffxTL5pgRfHnl4RZMCT23fIZ0U+252G6i 2DLq0GnbYxWs9NyXygHd/1ZwL9K2YcxqfzJ9CouAJKPWAwUJnkc/9Xf+u/4UVAf0FFNl hi6MBo/P4gnGWVr+9cRi+/qUGJGFOFEs/wxPSZHGlVUbEchasFYWnue/CRQo1JzRhRMm OJcumMaH5Yc2cQgs1iTOgbKTTzmVsMwbPJZdf9hzWglyYJTXYqpt8bVVjNRhU8A/wBep 02QzYeqTAPQjq74TbSPzj/ffZf2pvpYR6Djj95zC2vmyoPLEioI/Xc3zJjYJofZMhDUk WvSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=h4+76MFU; 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=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sz15-20020a1709078b0f00b0078ddc074afdsi10696973ejc.577.2022.10.19.02.11.13; Wed, 19 Oct 2022 02:11:39 -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=@linuxfoundation.org header.s=korg header.b=h4+76MFU; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232214AbiJSJIB (ORCPT + 99 others); Wed, 19 Oct 2022 05:08:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232286AbiJSJF0 (ORCPT ); Wed, 19 Oct 2022 05:05:26 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 161209F760; Wed, 19 Oct 2022 01:59:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2C4D661824; Wed, 19 Oct 2022 08:47:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37F8FC433B5; Wed, 19 Oct 2022 08:47:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169242; bh=1uVmc6hJkhsVlg30rXcmh4sw1hCaTQ5SkWgcWSh8PLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h4+76MFUHESST6hc2jYxiMwVGbUVAVDySqVEEIbCtuyzpMeU176PqfzyrFPp/5z14 0PFqKm/PVg2ENRpYApeAbHWGYdH+C74HpO903rf5sCiXUqlTr/gqNsfEB1Ytgy1LFw bwGtc2SLkFlMU3xWMipTQchpUP8VC8g645lv3bks= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xuewen Yan , Viresh Kumar , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 6.0 207/862] thermal: cpufreq_cooling: Check the policy first in cpufreq_cooling_register() Date: Wed, 19 Oct 2022 10:24:54 +0200 Message-Id: <20221019083259.160174548@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747106607011958160?= X-GMAIL-MSGID: =?utf-8?q?1747106607011958160?= From: Xuewen Yan [ Upstream commit cff895277c8558221ba180aefe26799dcb4eec86 ] Since the policy needs to be accessed first when obtaining cpu devices, first check whether the policy is legal before this. Fixes: 5130802ddbb1 ("thermal: cpu_cooling: Switch to QoS requests for freq limits") Signed-off-by: Xuewen Yan Acked-by: Viresh Kumar Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/thermal/cpufreq_cooling.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/cpufreq_cooling.c b/drivers/thermal/cpufreq_cooling.c index b76293cc989c..7838b6e2dba5 100644 --- a/drivers/thermal/cpufreq_cooling.c +++ b/drivers/thermal/cpufreq_cooling.c @@ -501,17 +501,17 @@ __cpufreq_cooling_register(struct device_node *np, struct thermal_cooling_device_ops *cooling_ops; char *name; + if (IS_ERR_OR_NULL(policy)) { + pr_err("%s: cpufreq policy isn't valid: %p\n", __func__, policy); + return ERR_PTR(-EINVAL); + } + dev = get_cpu_device(policy->cpu); if (unlikely(!dev)) { pr_warn("No cpu device for cpu %d\n", policy->cpu); return ERR_PTR(-ENODEV); } - if (IS_ERR_OR_NULL(policy)) { - pr_err("%s: cpufreq policy isn't valid: %p\n", __func__, policy); - return ERR_PTR(-EINVAL); - } - i = cpufreq_table_count_valid_entries(policy); if (!i) { pr_debug("%s: CPUFreq table not found or has no valid entries\n",