From patchwork Tue Sep 29 11:00:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 262888 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=unavailable 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 7DD64C4727C for ; Tue, 29 Sep 2020 12:44:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3247C208B8 for ; Tue, 29 Sep 2020 12:44:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601383456; bh=pZdPBhjCbkeixyqGuvLsmWtPpZc48xi+WJ8qgdxG2Xc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Kp9atlVO0uvwcotbfFokWOKnsHZPjOf8oKsdRlSKi85hXNOlZcrYr5DG6yMBSgGhX YMJTvPCtURV2Pm2ARwfNb8zbN5ng45K3iLGrgUIvAxLIQ+F1n+Yfro2/cDtSf5JMPR 4KCD4y0H18Y24ZtaoHzTgOfyESCDZ9FOr12A9Ysw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733207AbgI2Mny (ORCPT ); Tue, 29 Sep 2020 08:43:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:49872 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728456AbgI2LJc (ORCPT ); Tue, 29 Sep 2020 07:09:32 -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 84F54221E7; Tue, 29 Sep 2020 11:09:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601377772; bh=pZdPBhjCbkeixyqGuvLsmWtPpZc48xi+WJ8qgdxG2Xc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IUUsZ9m9wSiSUIy0AFcgoP0mtwj1mQZ97MuQdUvEEF5cXV/+hZSu6HpEiZJS7lMW0 Rntpfab4KawC/tfpJ0POAFNuJNtpGBlog1X2XRP5GVc4WCpaJYIl5TxPTBzXltPNH0 hwwlFGiiqaWeCCLyQ7RleHjX93fh/lkFUE2FU8mU= 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 4.9 067/121] cpufreq: powernv: Fix frame-size-overflow in powernv_cpufreq_work_fn Date: Tue, 29 Sep 2020 13:00:11 +0200 Message-Id: <20200929105933.488388903@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929105930.172747117@linuxfoundation.org> References: <20200929105930.172747117@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 b4fc65512aad3..c3b05676e0dbe 100644 --- a/drivers/cpufreq/powernv-cpufreq.c +++ b/drivers/cpufreq/powernv-cpufreq.c @@ -802,6 +802,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; @@ -816,12 +817,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();