Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp645094rwl; Wed, 29 Mar 2023 06:49:26 -0700 (PDT) X-Google-Smtp-Source: AK7set+iCW+hZi6NiFxea6Xq5525xA4w/aAJMWHiQEZY8RywRzHzjXCleh6Og5DVaV1P7HjtL5Q8 X-Received: by 2002:a05:6a20:8c14:b0:db:da69:3deb with SMTP id j20-20020a056a208c1400b000dbda693debmr15468406pzh.21.1680097766032; Wed, 29 Mar 2023 06:49:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680097766; cv=none; d=google.com; s=arc-20160816; b=vVgTEaX4ZjZFVm72IVjdMUDEwIY4zH3vPCQ951ZEh9KAG/F7n68U4+CfIADm8eNraW vnSg8r4R5wtpPJjX/FBV0EjkkBTjyVWqoC7ySywgJveJDcHVoj+7DKnrd6s7R5O38MvL a2V44lb/vqaOJu+tkEg4m9y37Ljta/ufCp8lfAeVRhbFmAIVSfFqSqmZupLkNdT90Ibw 6Urtkhs3bbr5PsExn/dWlcB30TqEdR2NCNZ/GzfSAs8WqlCqeX+qAKSMjiFqtyCmAGS6 5FFMdfzKLa7pyYqcY4vdIbWwPf7stbyjeIWQm9eA+vT/TPCSoQ69TvG9Ic/0n8H9avnd Sa2A== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=UiPBpxfgqtblG7e87/gO/rTDIyusVpWOK3LN9PbGo4M=; b=rZZNDN5kfWM6DNGFsVz1MQJKoC2w17lO24H6PrQlgJGhAoRqFGyBQRYNeVAU2f/gjH BCBj5sVvdzaJUL9/fR1faNxMaDgWEPht9c3l+v4XVhPNDrCXixr7VPLB4TInOy+CsLPP EoVzxwXdHrX9hqGMCzZgkIvOLiTe+etGSPbCwwQM9bf5ucx0K6GXnnj0gg+vvQp4zFXQ NOCVED9f8m0ePY0FF3N9NQb/mwVLskGplDRSUX4VSjCuzhdjjoHEKO8i0jPnRYYfcUCz bPhtMZYZCdHi0yHej8+c3zHxf8+AWlRLSehIgDYp/rZW6txRFVA4STPXFUB0jmcO9oJH U8OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=eOOy+X26; 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=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h187-20020a636cc4000000b00513559eb9a9si6881670pgc.754.2023.03.29.06.49.14; Wed, 29 Mar 2023 06:49:26 -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=@linux.dev header.s=key1 header.b=eOOy+X26; 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=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230348AbjC2Ngh (ORCPT + 99 others); Wed, 29 Mar 2023 09:36:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229601AbjC2Ngg (ORCPT ); Wed, 29 Mar 2023 09:36:36 -0400 Received: from out-46.mta0.migadu.com (out-46.mta0.migadu.com [IPv6:2001:41d0:1004:224b::2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0B2549DF 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 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,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 __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); -- 2.25.1