* [PATCH] PM / devfreq: events: fix excessive stack usage @ 2019-10-22 14:26 ` Arnd Bergmann 2019-11-01 6:51 ` Chanwoo Choi [not found] ` <CGME20191111060017epcas1p37c624e81f5421842a5a31136b4cba678@epcas1p3.samsung.com> 0 siblings, 2 replies; 4+ messages in thread From: Arnd Bergmann @ 2019-10-22 14:26 UTC (permalink / raw) To: Chanwoo Choi, MyungJoo Ham, Kyungmin Park, Kukjin Kim, Krzysztof Kozlowski Cc: Arnd Bergmann, Lukasz Luba, linux-pm, linux-arm-kernel, linux-samsung-soc, linux-kernel 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> --- 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 87b42055e6bc..302e466549d3 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->name); switch (id) { case PPMU_PMNCNT0: -- 2.20.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] PM / devfreq: events: fix excessive stack usage 2019-10-22 14:26 ` [PATCH] PM / devfreq: events: fix excessive stack usage Arnd Bergmann @ 2019-11-01 6:51 ` Chanwoo Choi [not found] ` <CGME20191111060017epcas1p37c624e81f5421842a5a31136b4cba678@epcas1p3.samsung.com> 1 sibling, 0 replies; 4+ messages in thread From: Chanwoo Choi @ 2019-11-01 6:51 UTC (permalink / raw) To: Arnd Bergmann, MyungJoo Ham, Kyungmin Park, Kukjin Kim, Krzysztof Kozlowski Cc: Lukasz Luba, linux-pm, linux-arm-kernel, linux-samsung-soc, linux-kernel Hi Arnd, On 19. 10. 22. 오후 11:26, Arnd Bergmann wrote: > 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> > --- > 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 87b42055e6bc..302e466549d3 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->name); I got that the original exynos_ppmu_find_ppmu_id() function has the bug. If 'events' node contains the one more events, it will be failed. Because 'events' node only contained the only one event on device-tree node on real use-case, the problem had not happened. 'desc' indicates the array. So, instead of desc->name, have to use 'desc[j].name correctly. And I'll fix the fundamental bug on separate patch. > > switch (id) { > case PPMU_PMNCNT0: > -- Best Regards, Chanwoo Choi Samsung Electronics ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <CGME20191111060017epcas1p37c624e81f5421842a5a31136b4cba678@epcas1p3.samsung.com>]
* [PATCH v2] PM / devfreq: events: Fix excessive stack usage [not found] ` <CGME20191111060017epcas1p37c624e81f5421842a5a31136b4cba678@epcas1p3.samsung.com> @ 2019-11-11 6:05 ` Chanwoo Choi 2019-11-11 6:07 ` Chanwoo Choi 0 siblings, 1 reply; 4+ messages in thread From: Chanwoo Choi @ 2019-11-11 6:05 UTC (permalink / raw) To: arnd, myungjoo.ham, kyungmin.park, krzk, kgene Cc: linux-pm, linux-arm-kernel, linux-kernel, linux-samsung-soc, chanwoo, Chanwoo Choi 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: -- 2.17.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] PM / devfreq: events: Fix excessive stack usage 2019-11-11 6:05 ` [PATCH v2] PM / devfreq: events: Fix " Chanwoo Choi @ 2019-11-11 6:07 ` Chanwoo Choi 0 siblings, 0 replies; 4+ messages in thread From: Chanwoo Choi @ 2019-11-11 6:07 UTC (permalink / raw) To: arnd, myungjoo.ham, kyungmin.park, krzk, kgene Cc: linux-pm, linux-arm-kernel, linux-kernel, linux-samsung-soc, chanwoo 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-11-11 6:02 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <CGME20191022142726epcas3p4c09cde8944f5e8f1472b496e1e1fbccc@epcas3p4.samsung.com> 2019-10-22 14:26 ` [PATCH] PM / devfreq: events: fix excessive stack usage 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 is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).