From patchwork Tue Sep 29 10:58:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 263280 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51FA7C4727F for ; Tue, 29 Sep 2020 11:39:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 12FDB21941 for ; Tue, 29 Sep 2020 11:39:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601379577; bh=HTY1zQoaAK6BEfTs3XHzI6+YJrvBSelh3jUsNGfhxW8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=XPbCOck5eQYpPPhkYzcN2syy2IYgH/E7+4ByifD1VyigibPCUy86LxYPihRJCQ3LG l5fGj12SbybUQtaJVkyHInHmYB960nZp+wya9gJrbHnpRJvn1ib3dLSnwwsDHbRbvg NILM39F6xNGNoq5CUVgTzJGZCLGYBDH21X2CkiYk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729831AbgI2Ljf (ORCPT ); Tue, 29 Sep 2020 07:39:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:34378 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730438AbgI2Lje (ORCPT ); Tue, 29 Sep 2020 07:39:34 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EB60221941; Tue, 29 Sep 2020 11:39:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601379563; bh=HTY1zQoaAK6BEfTs3XHzI6+YJrvBSelh3jUsNGfhxW8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B3wX/+0AHpuSKzUi8SyXVXrybeAi9s+SBOy9q6HCJ8zNhdQHNi9qiEsICMnU/bH4a fygSDlMmQfBwlbzKFw7VJvGDN93oFBvCeXIPqj13a3wCp+Wxi0hQjCVTXTtSRsFZCx ZhlTPOftJEYVv7eO/MqvdXTF8KCDystxuKNHDCUY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pratik Rajesh Sampat , Daniel Axtens , Michael Ellerman , Sasha Levin Subject: [PATCH 5.4 190/388] cpufreq: powernv: Fix frame-size-overflow in powernv_cpufreq_work_fn Date: Tue, 29 Sep 2020 12:58:41 +0200 Message-Id: <20200929110019.678527867@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929110010.467764689@linuxfoundation.org> References: <20200929110010.467764689@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Pratik Rajesh Sampat [ Upstream commit d95fe371ecd28901f11256c610b988ed44e36ee2 ] The patch avoids allocating cpufreq_policy on stack hence fixing frame size overflow in 'powernv_cpufreq_work_fn' Fixes: 227942809b52 ("cpufreq: powernv: Restore cpu frequency to policy->cur on unthrottling") Signed-off-by: Pratik Rajesh Sampat Reviewed-by: Daniel Axtens Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20200316135743.57735-1-psampat@linux.ibm.com Signed-off-by: Sasha Levin --- drivers/cpufreq/powernv-cpufreq.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c index 1806b1da43665..3a2f022f6bde2 100644 --- a/drivers/cpufreq/powernv-cpufreq.c +++ b/drivers/cpufreq/powernv-cpufreq.c @@ -902,6 +902,7 @@ static struct notifier_block powernv_cpufreq_reboot_nb = { void powernv_cpufreq_work_fn(struct work_struct *work) { struct chip *chip = container_of(work, struct chip, throttle); + struct cpufreq_policy *policy; unsigned int cpu; cpumask_t mask; @@ -916,12 +917,14 @@ void powernv_cpufreq_work_fn(struct work_struct *work) chip->restore = false; for_each_cpu(cpu, &mask) { int index; - struct cpufreq_policy policy; - cpufreq_get_policy(&policy, cpu); - index = cpufreq_table_find_index_c(&policy, policy.cur); - powernv_cpufreq_target_index(&policy, index); - cpumask_andnot(&mask, &mask, policy.cpus); + policy = cpufreq_cpu_get(cpu); + if (!policy) + continue; + index = cpufreq_table_find_index_c(policy, policy->cur); + powernv_cpufreq_target_index(policy, index); + cpumask_andnot(&mask, &mask, policy->cpus); + cpufreq_cpu_put(policy); } out: put_online_cpus();