LKML Archive on lore.kernel.org
 help / color / Atom feed
From: Chanwoo Choi <cw00.choi@samsung.com>
To: arnd@arndb.de, myungjoo.ham@samsung.com,
	kyungmin.park@samsung.com, krzk@kernel.org, kgene@kernel.org
Cc: linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
	chanwoo@kernel.org
Subject: Re: [PATCH v2] PM / devfreq: events: Fix excessive stack usage
Date: Mon, 11 Nov 2019 15:07:49 +0900
Message-ID: <665c348d-a0d6-c111-65a2-db7447553b9d@samsung.com> (raw)
In-Reply-To: <20191111060557.15650-1-cw00.choi@samsung.com>

On 11/11/19 3:05 PM, Chanwoo Choi wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> 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 <arnd@arndb.de>
> [cw00.choi: Fix the issue from 'desc->name' to 'desc[j].name']
> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
> ---
> Changes from v1:
> - Fix the issue from 'desc->name' to 'desc[j].name'
> 
>  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 85c7a77bf3f0..055deea42c37 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:
> 

Applied it. Thanks.

-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

      reply index

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20191022142726epcas3p4c09cde8944f5e8f1472b496e1e1fbccc@epcas3p4.samsung.com>
2019-10-22 14:26 ` [PATCH] PM / devfreq: events: fix " Arnd Bergmann
2019-11-01  6:51   ` Chanwoo Choi
     [not found]   ` <CGME20191111060017epcas1p37c624e81f5421842a5a31136b4cba678@epcas1p3.samsung.com>
2019-11-11  6:05     ` [PATCH v2] PM / devfreq: events: Fix " Chanwoo Choi
2019-11-11  6:07       ` Chanwoo Choi [this message]

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=665c348d-a0d6-c111-65a2-db7447553b9d@samsung.com \
    --to=cw00.choi@samsung.com \
    --cc=arnd@arndb.de \
    --cc=chanwoo@kernel.org \
    --cc=kgene@kernel.org \
    --cc=krzk@kernel.org \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=myungjoo.ham@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git