From patchwork Wed Mar 29 13:36:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yajun Deng X-Patchwork-Id: 668500 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 71E2FC74A5B for ; Wed, 29 Mar 2023 13:36:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229753AbjC2Nge (ORCPT ); Wed, 29 Mar 2023 09:36:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229601AbjC2Ngd (ORCPT ); Wed, 29 Mar 2023 09:36:33 -0400 Received: from out-9.mta0.migadu.com (out-9.mta0.migadu.com [91.218.175.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BE1349F6 for ; Wed, 29 Mar 2023 06:36:32 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1680096990; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=UiPBpxfgqtblG7e87/gO/rTDIyusVpWOK3LN9PbGo4M=; b=eOOy+X26B7Q/Qcfu70uyttKgSCXxeLseZzn7JN7s8AO4yC9+Uo7gov+4GrGwUSCBsibb0A XWMtcwpFIykKphDfIpGJGTlk09NJHo6tok2qWscH1ZBlQq7z+ou4VeqPnGMdwUXQVUS5Oe FOWa45iFSfbigpVe3u5fYpwqWJ+THzo= From: Yajun Deng To: rafael@kernel.org, viresh.kumar@linaro.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Yajun Deng Subject: [PATCH] cpufreq: Fix policy->freq_table is NULL in __cpufreq_driver_target() Date: Wed, 29 Mar 2023 21:36:00 +0800 Message-Id: <20230329133600.908723-1-yajun.deng@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org __resolve_freq() may be return target_freq if policy->freq_table is NULL. In this case, it should return -EINVAL before __target_index(). Signed-off-by: Yajun Deng --- drivers/cpufreq/cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index c0e5be0fe2d6..308a3df1a940 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2299,7 +2299,7 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, return cpufreq_driver->target(policy, target_freq, relation); } - if (!cpufreq_driver->target_index) + if (!cpufreq_driver->target_index || !policy->freq_table) return -EINVAL; return __target_index(policy, policy->cached_resolved_idx);