Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1637086ybv; Fri, 21 Feb 2020 00:45:38 -0800 (PST) X-Google-Smtp-Source: APXvYqwNzkXJt6uc0p0UX64FxYC/7gFgG93q+yiMlgRLyZWSLV19e89MZig+cnxBB8sfMzdYBW6n X-Received: by 2002:aca:514e:: with SMTP id f75mr1107272oib.103.1582274738430; Fri, 21 Feb 2020 00:45:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582274738; cv=none; d=google.com; s=arc-20160816; b=o5cDEzs643HSTZ3vEwhfiyQHoY/vSD+AqFjc/ia1WGlJ94MEwtJT/YPqQ5ys+inUmt 4J1QRBBzxH7pLfDk8lTsmXd/JsA9R0nQqcu0eu+ZrLOr4OxvxoQiOvFOZKXM42VUv7t9 DXg0o6NFNj7h+tEuH2gCN64ScbhcTZK7ew7yDFPAxs4gKwS6nVoXhRpKiFgcZ9tWaQAs 8+Eq+l1IfjK34wM080uejVw2R0OP7RO+egqgqUNY+qKjF0mlMCszeL2KigUjuD6kzeSS vFDFKQyE4DacO18Z0phGeusmuzrI6xjBb42F2nNANtKvdtSTJFJwEohTVlHmC3pzcROf q+iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IHn0t+k5G8AWKWyNb/WvbDKczySc2WQPZQlMygmL4L8=; b=g7gteQNiWTVmqQYdpFTJVyqmcFMBlegtflcesczfLMxb6b62BkEkyWREqrnQtYdnK+ L7nFJ36n2OT00tFWI8HTIxHINMRr16P86XJDOl4wRNFPbzepDAdPJRhc1JAqdAvLeexK tHbxbyzgj/tXxU+DJ5B7IKlXWWwsFJs0dRtzQmZWRMxVKZM1Zy6Zj1Yw1bNwS55maota 13sHqYprkTHgboaae5Lftg6o5vSDj9C7t2Bigh5KuAYXGFBXe4XQWoJJwp5idf86wrat Y3mXqCG9bNn4wJhJ8tTW1Iu0p0mah8JOo9twe6KcfsJRtErk1fREMz/Ol9KJir5vyyz5 o/iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nOrmEFvF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s11si498528oic.57.2020.02.21.00.45.26; Fri, 21 Feb 2020 00:45:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nOrmEFvF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730169AbgBUIou (ORCPT + 99 others); Fri, 21 Feb 2020 03:44:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:49262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729786AbgBUHvo (ORCPT ); Fri, 21 Feb 2020 02:51:44 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 CBB932073A; Fri, 21 Feb 2020 07:51:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582271504; bh=K+GbBvUYMrSGOr40poPKHl1+OJzijRKgppJ0R0XLZ9M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nOrmEFvFhWy07iWiJmi3xh8hW2JP3I+vjLPNsg2+lbienWoHTwjW4GBcuhZ9pjrjK jkO6ft05xDO3zt6uqTy1B9A61t1AuiVMw8OK9WVPUoOXiea1rdLgUHpXxgC8bZ2N18 lUnEi6s61PvbOjVmZnjsKS/t3JTEpySuX/kGjTgc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Chanwoo Choi , Sasha Levin Subject: [PATCH 5.5 190/399] PM / devfreq: exynos-ppmu: Fix excessive stack usage Date: Fri, 21 Feb 2020 08:38:35 +0100 Message-Id: <20200221072421.275322914@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072402.315346745@linuxfoundation.org> References: <20200221072402.315346745@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann [ Upstream commit d4556f5e99d5f603913bac01adaff8670cb2d08b ] Putting a 'struct devfreq_event_dev' object on the stack is generally a bad idea and here it leads to a warnig about potential stack overflow: drivers/devfreq/event/exynos-ppmu.c:643:12: error: stack frame size of 1040 bytes in function 'exynos_ppmu_probe' [-Werror,-Wframe-larger-than=] There is no real need for the device structure, only the string inside it, so add an internal helper function that simply takes the string as its argument and remove the device structure. Fixes: 1dd62c66d345 ("PM / devfreq: events: extend events by type of counted data") Signed-off-by: Arnd Bergmann [cw00.choi: Fix the issue from 'desc->name' to 'desc[j].name'] Signed-off-by: Chanwoo Choi Signed-off-by: Sasha Levin --- drivers/devfreq/event/exynos-ppmu.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/devfreq/event/exynos-ppmu.c b/drivers/devfreq/event/exynos-ppmu.c index 85c7a77bf3f0d..055deea42c373 100644 --- a/drivers/devfreq/event/exynos-ppmu.c +++ b/drivers/devfreq/event/exynos-ppmu.c @@ -101,17 +101,22 @@ static struct __exynos_ppmu_events { PPMU_EVENT(dmc1_1), }; -static int exynos_ppmu_find_ppmu_id(struct devfreq_event_dev *edev) +static int __exynos_ppmu_find_ppmu_id(const char *edev_name) { int i; for (i = 0; i < ARRAY_SIZE(ppmu_events); i++) - if (!strcmp(edev->desc->name, ppmu_events[i].name)) + if (!strcmp(edev_name, ppmu_events[i].name)) return ppmu_events[i].id; return -EINVAL; } +static int exynos_ppmu_find_ppmu_id(struct devfreq_event_dev *edev) +{ + return __exynos_ppmu_find_ppmu_id(edev->desc->name); +} + /* * The devfreq-event ops structure for PPMU v1.1 */ @@ -556,13 +561,11 @@ static int of_get_devfreq_events(struct device_node *np, * use default if not. */ if (info->ppmu_type == EXYNOS_TYPE_PPMU_V2) { - struct devfreq_event_dev edev; int id; /* Not all registers take the same value for * read+write data count. */ - edev.desc = &desc[j]; - id = exynos_ppmu_find_ppmu_id(&edev); + id = __exynos_ppmu_find_ppmu_id(desc[j].name); switch (id) { case PPMU_PMNCNT0: -- 2.20.1