Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp878420pxk; Thu, 17 Sep 2020 20:07:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIX9Svuw8sEtJs5n6MIznfhcN/HZ6WqvQQkb8jmuZ6eJoLD8IjCTqSB3XrIxv8WiUUIYlr X-Received: by 2002:a17:906:3bca:: with SMTP id v10mr33461358ejf.57.1600398439887; Thu, 17 Sep 2020 20:07:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600398439; cv=none; d=google.com; s=arc-20160816; b=BS0VZgbWpJeZqW5NAiNG/DLKFmqW1DZ2YlSv2j3M0ZoT8ISJ7xHjetwjH0gXL7ZZPz /a50ZNuQ70YNKS0bM9gIFs4+YTSHavWz5eGboOg5X4SAkkL3SxJ/BMkMikBOIe3/Rm64 RAbUaxEpD+HEPqPiCAp3DNAoLp3aJKvZ7XNNKlksDB8PrGhUiMpl84o9zkS6jrRLTt8l BmDWlUFgOSOxEaJnVoZ7Yr0PHsjfpXS1/GIrTNvDD7F3gb5quEhI57ujbqXCyEBt9Tdt QNjP40f7ht39IE/1C+wxqhBJ1soa7QH12Y0SEM3MAMO880bdpw93R7kwvy1HsWnwIdYa dnew== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=L3MeKoTW7wFBIyRCk5ZL8zga6UrGTxr5awg/BaStCb0=; b=HN0qBMNR2uPgf78poO7ApqIIlbH15hZF02Nu8ixjdSXyUcr/WNMTvUedJVMaxmSoSu XOeEeyO31YjeOb0Qn6qD9rwvMqQ/C4U4vmd30v7cAnfP/xCKxiSTLDZ6WT7/IumJcK5/ Sr4EXMQqNDBeMyvlH7kNjtuTsvBNbGCc51nLCvktsJT+M6jtoNvUIoxKkJnxt5+HIAex dSKVEXIVlV3sp1Gu11+R2DX8ErXKk7/GtfZAGQ24JovqaBT6B4LtzjKuIPb4EFbf9k+x ARdLr64iKGrF0h6SRlH4DoYSW0CGIKCb313zjtsTpkZ/lWF7IT6ABKzy5m1sveeMFcz/ brBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yoQU0RZT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u10si1251551ejy.154.2020.09.17.20.06.56; Thu, 17 Sep 2020 20:07:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yoQU0RZT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730542AbgIRDDC (ORCPT + 99 others); Thu, 17 Sep 2020 23:03:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:53314 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726704AbgIRCFM (ORCPT ); Thu, 17 Sep 2020 22:05:12 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2A9AE238E3; Fri, 18 Sep 2020 02:05:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394711; bh=HTY1zQoaAK6BEfTs3XHzI6+YJrvBSelh3jUsNGfhxW8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yoQU0RZTUiEgXZ3xHMrWr2G/VV7lPyLkynrZTWekKxLEWpAVnC5+En5/OmYKaqIYf sazQF/zerF2UkFnu8J2e0z0/sudMrE8MZzVkAeydOYBm2BuHHKcOcQ8LOWLncOwYxP 92rAH2gRclES8UMPWvXhBD3duFePikeIwIgFwJDs= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pratik Rajesh Sampat , Daniel Axtens , Michael Ellerman , Sasha Levin , linux-pm@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 196/330] cpufreq: powernv: Fix frame-size-overflow in powernv_cpufreq_work_fn Date: Thu, 17 Sep 2020 21:58:56 -0400 Message-Id: <20200918020110.2063155-196-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(); -- 2.25.1