From patchwork Sat Oct 22 07:20:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7264 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1091752wrr; Sat, 22 Oct 2022 00:51:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Wa8GTcEDWKBM4GFBWLv/Gi+nGYaxrQphMVZ6XSzpwQVr8ywE+szJrywhU0nSZG7r/U/yO X-Received: by 2002:a05:6a00:b83:b0:565:caea:38be with SMTP id g3-20020a056a000b8300b00565caea38bemr23029146pfj.72.1666425106715; Sat, 22 Oct 2022 00:51:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666425106; cv=none; d=google.com; s=arc-20160816; b=TyH0+hYjWyO+i8/sSd3QxM7Fn0U5gMmGGq8WbyZFeS2Ou3XCqyFFiOqjs1JpI/DnTk mEgTRsZLUSlyPAfgDXFrkMzPJ1fUZty/NK3In0MBqB0wnYxHMLHl/VtQWObx+INS9yqr b9GyAmyaWbpW2qYLJSF3ZitrCCXI8Iz9pxOlRbjdM20Ebq5HXzcjUGsZOJSRqDnbI4lO Btrvkn9qecx0ZJnkZQLwtiIFnqxXSBwTA5ZSDdgxUjgLBHuUcFPomSK475t/Wy/XlV21 FVJ4ucP611V5aktNMuZFiGD5i2szv7i5n8CkXE9xGqQgB1yuleD3I2NtOZf/9UDFTEC0 sP2w== 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=dzTYPRsVQNg5WJvwx8PcMcPJ4i8hKSjvtOGBSoJOax0=; b=yvdq+dPagJrlFeuqAfWn01Yig8HVQqvoZOqcUPsyfVkpMf0lBVCpM5vlvzpXE/8XNg tJ3rW+pfRWl9RGYPtCU7qzKb7v7mw/9fKoSTTVJf1aOHvNOYRJ9zx4PdcSlejolLOwNh KlEF4CqDb+dDanTvIeKPNjM1cDL/Vdw1jF8BGiN2SrPazmCGKLxaIvTtK57XEOXeKu2y FvrkBu0a9014gWH3obiU8aAwjqotUY99/HI8wVol33tUpK5zIdRw+QMyAEnHfO/9hRqU IFs+dmgOwGK1nRJurG8+h7ERYMm/TZ38UL559ZY1hqPOELESsrepfFBFpHoIaI1zh+aR Np0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="VFH/qmxv"; 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 p8-20020a170902a40800b00178297641d4si25014251plq.287.2022.10.22.00.51.34; Sat, 22 Oct 2022 00:51:46 -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="VFH/qmxv"; 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 S231846AbiJVHvT (ORCPT + 99 others); Sat, 22 Oct 2022 03:51:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231810AbiJVHtL (ORCPT ); Sat, 22 Oct 2022 03:49:11 -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 ABA2D24B305; Sat, 22 Oct 2022 00:45:40 -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 21E8760B98; Sat, 22 Oct 2022 07:42:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 390DFC433D6; Sat, 22 Oct 2022 07:42:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424527; bh=Hp+4Nn5q4h6t3PT29RYWpNp8hMMj6u2yuQ2wULGvs5g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VFH/qmxvTMkEZZ6NpAyOVQHCuc1zoQMV6T+S4OBLVpbrA1IE/7470jXQfUQRxIt8c AMDiuuNQU+9+nJqiE3gScaZ9rnRLmUqOycH9cSJz0Lb0ktR/avpsmy7tbvUIkzavjB 6En0VzsuySh8JkJBzg7iwj2guokApAAFd3lrjw84= 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 5.19 180/717] thermal: cpufreq_cooling: Check the policy first in cpufreq_cooling_register() Date: Sat, 22 Oct 2022 09:20:59 +0200 Message-Id: <20221022072447.444358733@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747373372815302920?= X-GMAIL-MSGID: =?utf-8?q?1747373372815302920?= 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 dc19e7c80751..ca5746f53d9e 100644 --- a/drivers/thermal/cpufreq_cooling.c +++ b/drivers/thermal/cpufreq_cooling.c @@ -530,17 +530,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",