From patchwork Tue Sep 29 10:59:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 262981 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 D3090C4727F for ; Tue, 29 Sep 2020 12:28:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 82ADA208B8 for ; Tue, 29 Sep 2020 12:28:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601382491; bh=i2k6psKD+dGUpLw0J0oosq21og7nGX/I57WbGKyndI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=hkpcXjRFKfwSWb61s/YdrVr+yoLkxJPhlBjrp/CC0uMgorGM1gzpB/ZCUUdsTil+K 8zbDIPMZnuHkvE55DK1OCYYVpppaHgLJAFDYvikXgiBBwAnYZdQVx3KD/BagV0icWb ELJI3SVtqQvsjRKgwVtTCws2bg+r3qIRIihvfSPM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732311AbgI2M2K (ORCPT ); Tue, 29 Sep 2020 08:28:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:49816 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729534AbgI2LdA (ORCPT ); Tue, 29 Sep 2020 07:33:00 -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 5D53823B2A; Tue, 29 Sep 2020 11:25:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601378750; bh=i2k6psKD+dGUpLw0J0oosq21og7nGX/I57WbGKyndI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ulJ8zbnhnpkifbdPrCE0jGi0+PLARS1fjn994MC9K9Tn54mnBH9567Z14RzeoMFDe rcgVtrK4tdzzT5VeDeq2o/e5EZY4HH31uuENltA7juQxrQLt7PXXG0iiOF00bOkNI5 lYEmkwP8gwiTQS/JhDJtsfooQFBZMaa/S3d2ldcg= 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.19 125/245] cpufreq: powernv: Fix frame-size-overflow in powernv_cpufreq_work_fn Date: Tue, 29 Sep 2020 12:59:36 +0200 Message-Id: <20200929105953.071665889@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929105946.978650816@linuxfoundation.org> References: <20200929105946.978650816@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 687c92ef76440..79942f7057576 100644 --- a/drivers/cpufreq/powernv-cpufreq.c +++ b/drivers/cpufreq/powernv-cpufreq.c @@ -903,6 +903,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; @@ -917,12 +918,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();