* [PATCH] omap: pm: Fix overflow when doing powerdomain deps lookups.
@ 2009-08-11 2:00 Mike Chan
2009-08-11 14:38 ` Kevin Hilman
0 siblings, 1 reply; 6+ messages in thread
From: Mike Chan @ 2009-08-11 2:00 UTC (permalink / raw)
To: linux-omap; +Cc: khilman, Mike Chan
Signed-off-by: Mike Chan <mike@android.com>
---
arch/arm/mach-omap2/powerdomain.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
index 0334609..6077629 100644
--- a/arch/arm/mach-omap2/powerdomain.c
+++ b/arch/arm/mach-omap2/powerdomain.c
@@ -90,7 +90,7 @@ static struct powerdomain *_pwrdm_deps_lookup(struct powerdomain *pwrdm,
if (!pwrdm || !deps || !omap_chip_is(pwrdm->omap_chip))
return ERR_PTR(-EINVAL);
- for (pd = deps; pd; pd++) {
+ for (pd = deps; pd->pwrdm_name; pd++) {
if (!omap_chip_is(pd->omap_chip))
continue;
--
1.5.4.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] omap: pm: Fix overflow when doing powerdomain deps lookups.
2009-08-11 2:00 [PATCH] omap: pm: Fix overflow when doing powerdomain deps lookups Mike Chan
@ 2009-08-11 14:38 ` Kevin Hilman
2009-08-11 18:11 ` Mike Chan
0 siblings, 1 reply; 6+ messages in thread
From: Kevin Hilman @ 2009-08-11 14:38 UTC (permalink / raw)
To: Mike Chan; +Cc: linux-omap
Mike Chan <mike@android.com> writes:
> Signed-off-by: Mike Chan <mike@android.com>
> ---
> arch/arm/mach-omap2/powerdomain.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
> index 0334609..6077629 100644
> --- a/arch/arm/mach-omap2/powerdomain.c
> +++ b/arch/arm/mach-omap2/powerdomain.c
> @@ -90,7 +90,7 @@ static struct powerdomain *_pwrdm_deps_lookup(struct powerdomain *pwrdm,
> if (!pwrdm || !deps || !omap_chip_is(pwrdm->omap_chip))
> return ERR_PTR(-EINVAL);
>
> - for (pd = deps; pd; pd++) {
> + for (pd = deps; pd->pwrdm_name; pd++) {
Maybe should be:
for (pd = deps; pd && pd->pwrdm_name; pd++) {
?
>
> if (!omap_chip_is(pd->omap_chip))
> continue;
Also, a descriptive changelog would be helpful here describing the
conditions where you saw overflow etc.
Kevin
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] omap: pm: Fix overflow when doing powerdomain deps lookups.
2009-08-11 14:38 ` Kevin Hilman
@ 2009-08-11 18:11 ` Mike Chan
2009-08-12 0:14 ` Kevin Hilman
2009-08-12 6:32 ` Paul Walmsley
0 siblings, 2 replies; 6+ messages in thread
From: Mike Chan @ 2009-08-11 18:11 UTC (permalink / raw)
To: Kevin Hilman; +Cc: linux-omap
On Tue, Aug 11, 2009 at 7:38 AM, Kevin
Hilman<khilman@deeprootsystems.com> wrote:
> Mike Chan <mike@android.com> writes:
>
>> Signed-off-by: Mike Chan <mike@android.com>
>> ---
>> arch/arm/mach-omap2/powerdomain.c | 2 +-
>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
>> index 0334609..6077629 100644
>> --- a/arch/arm/mach-omap2/powerdomain.c
>> +++ b/arch/arm/mach-omap2/powerdomain.c
>> @@ -90,7 +90,7 @@ static struct powerdomain *_pwrdm_deps_lookup(struct powerdomain *pwrdm,
>> if (!pwrdm || !deps || !omap_chip_is(pwrdm->omap_chip))
>> return ERR_PTR(-EINVAL);
>>
>> - for (pd = deps; pd; pd++) {
>> + for (pd = deps; pd->pwrdm_name; pd++) {
>
> Maybe should be:
>
> for (pd = deps; pd && pd->pwrdm_name; pd++) {
>
At the end of the list pd is a pointer to a NULL struct, so checking
if the address == NULL doesn't help here. In fact the original code
will just keep running past the struct to read who knows what in
memory.
This case manifests itself when from clkdms_setup() when enabling auto
idle for a clock domain and the clockdomain usecount is greater than
0. When _clkdm_add_autodeps() tries to add the a dependency that does
not exist in the powerdomain->wkdep_srcs array the for loop will run
past the wkdep_srcs array.
Currently in linux-omap you won't hit this because the not found case
is never executed, unless you start modifying powerdomains and their
wakeup/sleep deps.
--Mike
> ?
>
>>
>> if (!omap_chip_is(pd->omap_chip))
>> continue;
>
> Also, a descriptive changelog would be helpful here describing the
> conditions where you saw overflow etc.
>
> Kevin
>
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] omap: pm: Fix overflow when doing powerdomain deps lookups.
2009-08-11 18:11 ` Mike Chan
@ 2009-08-12 0:14 ` Kevin Hilman
2009-08-12 6:32 ` Paul Walmsley
1 sibling, 0 replies; 6+ messages in thread
From: Kevin Hilman @ 2009-08-12 0:14 UTC (permalink / raw)
To: Mike Chan; +Cc: linux-omap
Mike Chan <mike@android.com> writes:
> On Tue, Aug 11, 2009 at 7:38 AM, Kevin
> Hilman<khilman@deeprootsystems.com> wrote:
>> Mike Chan <mike@android.com> writes:
>>
>>> Signed-off-by: Mike Chan <mike@android.com>
>>> ---
>>> arch/arm/mach-omap2/powerdomain.c | 2 +-
>>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
>>> index 0334609..6077629 100644
>>> --- a/arch/arm/mach-omap2/powerdomain.c
>>> +++ b/arch/arm/mach-omap2/powerdomain.c
>>> @@ -90,7 +90,7 @@ static struct powerdomain *_pwrdm_deps_lookup(struct powerdomain *pwrdm,
>>> if (!pwrdm || !deps || !omap_chip_is(pwrdm->omap_chip))
>>> return ERR_PTR(-EINVAL);
>>>
>>> - for (pd = deps; pd; pd++) {
>>> + for (pd = deps; pd->pwrdm_name; pd++) {
>>
>> Maybe should be:
>>
>> for (pd = deps; pd && pd->pwrdm_name; pd++) {
>>
>
> At the end of the list pd is a pointer to a NULL struct, so checking
> if the address == NULL doesn't help here. In fact the original code
> will just keep running past the struct to read who knows what in
> memory.
I see that now, didn't notice the NULL struct terminators.
> This case manifests itself when from clkdms_setup() when enabling auto
> idle for a clock domain and the clockdomain usecount is greater than
> 0. When _clkdm_add_autodeps() tries to add the a dependency that does
> not exist in the powerdomain->wkdep_srcs array the for loop will run
> past the wkdep_srcs array.
Thanks, will add this as changelog and push to PM branch as well as
pm-2.6.29.
Kevin
> Currently in linux-omap you won't hit this because the not found case
> is never executed, unless you start modifying powerdomains and their
> wakeup/sleep deps.
>
> --Mike
>
>> ?
>>
>>>
>>> if (!omap_chip_is(pd->omap_chip))
>>> continue;
>>
>> Also, a descriptive changelog would be helpful here describing the
>> conditions where you saw overflow etc.
>>
>> Kevin
>>
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] omap: pm: Fix overflow when doing powerdomain deps lookups.
2009-08-11 18:11 ` Mike Chan
2009-08-12 0:14 ` Kevin Hilman
@ 2009-08-12 6:32 ` Paul Walmsley
2009-08-12 17:58 ` Mike Chan
1 sibling, 1 reply; 6+ messages in thread
From: Paul Walmsley @ 2009-08-12 6:32 UTC (permalink / raw)
To: Mike Chan; +Cc: Kevin Hilman, linux-omap
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1969 bytes --]
Hi Mike,
On Tue, 11 Aug 2009, Mike Chan wrote:
> On Tue, Aug 11, 2009 at 7:38 AM, Kevin
> Hilman<khilman@deeprootsystems.com> wrote:
> > Mike Chan <mike@android.com> writes:
> >
> >> Signed-off-by: Mike Chan <mike@android.com>
> >> ---
> >> arch/arm/mach-omap2/powerdomain.c | 2 +-
> >> 1 files changed, 1 insertions(+), 1 deletions(-)
> >>
> >> diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
> >> index 0334609..6077629 100644
> >> --- a/arch/arm/mach-omap2/powerdomain.c
> >> +++ b/arch/arm/mach-omap2/powerdomain.c
> >> @@ -90,7 +90,7 @@ static struct powerdomain *_pwrdm_deps_lookup(struct powerdomain *pwrdm,
> >> if (!pwrdm || !deps || !omap_chip_is(pwrdm->omap_chip))
> >> return ERR_PTR(-EINVAL);
> >>
> >> - for (pd = deps; pd; pd++) {
> >> + for (pd = deps; pd->pwrdm_name; pd++) {
> >
> > Maybe should be:
> >
> > for (pd = deps; pd && pd->pwrdm_name; pd++) {
> >
>
> At the end of the list pd is a pointer to a NULL struct, so checking
> if the address == NULL doesn't help here. In fact the original code
> will just keep running past the struct to read who knows what in
> memory.
>
> This case manifests itself when from clkdms_setup() when enabling auto
> idle for a clock domain and the clockdomain usecount is greater than
> 0. When _clkdm_add_autodeps() tries to add the a dependency that does
> not exist in the powerdomain->wkdep_srcs array the for loop will run
> past the wkdep_srcs array.
>
> Currently in linux-omap you won't hit this because the not found case
> is never executed, unless you start modifying powerdomains and their
> wakeup/sleep deps.
>
> --Mike
Thanks for the patch, this is correct. But the patch also should modify:
if (!pd)
return ERR_PTR(-ENOENT);
after the loop to be
if (!pd->pwrdm_name)
...
Could you revise this and resend?
thanks
- Paul
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] omap: pm: Fix overflow when doing powerdomain deps lookups.
2009-08-12 6:32 ` Paul Walmsley
@ 2009-08-12 17:58 ` Mike Chan
0 siblings, 0 replies; 6+ messages in thread
From: Mike Chan @ 2009-08-12 17:58 UTC (permalink / raw)
To: Paul Walmsley; +Cc: Kevin Hilman, linux-omap
On Tue, Aug 11, 2009 at 11:32 PM, Paul Walmsley<paul@pwsan.com> wrote:
> Hi Mike,
>
> On Tue, 11 Aug 2009, Mike Chan wrote:
>
>> On Tue, Aug 11, 2009 at 7:38 AM, Kevin
>> Hilman<khilman@deeprootsystems.com> wrote:
>> > Mike Chan <mike@android.com> writes:
>> >
>> >> Signed-off-by: Mike Chan <mike@android.com>
>> >> ---
>> >> arch/arm/mach-omap2/powerdomain.c | 2 +-
>> >> 1 files changed, 1 insertions(+), 1 deletions(-)
>> >>
>> >> diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
>> >> index 0334609..6077629 100644
>> >> --- a/arch/arm/mach-omap2/powerdomain.c
>> >> +++ b/arch/arm/mach-omap2/powerdomain.c
>> >> @@ -90,7 +90,7 @@ static struct powerdomain *_pwrdm_deps_lookup(struct powerdomain *pwrdm,
>> >> if (!pwrdm || !deps || !omap_chip_is(pwrdm->omap_chip))
>> >> return ERR_PTR(-EINVAL);
>> >>
>> >> - for (pd = deps; pd; pd++) {
>> >> + for (pd = deps; pd->pwrdm_name; pd++) {
>> >
>> > Maybe should be:
>> >
>> > for (pd = deps; pd && pd->pwrdm_name; pd++) {
>> >
>>
>> At the end of the list pd is a pointer to a NULL struct, so checking
>> if the address == NULL doesn't help here. In fact the original code
>> will just keep running past the struct to read who knows what in
>> memory.
>>
>> This case manifests itself when from clkdms_setup() when enabling auto
>> idle for a clock domain and the clockdomain usecount is greater than
>> 0. When _clkdm_add_autodeps() tries to add the a dependency that does
>> not exist in the powerdomain->wkdep_srcs array the for loop will run
>> past the wkdep_srcs array.
>>
>> Currently in linux-omap you won't hit this because the not found case
>> is never executed, unless you start modifying powerdomains and their
>> wakeup/sleep deps.
>>
>> --Mike
>
> Thanks for the patch, this is correct. But the patch also should modify:
>
> if (!pd)
> return ERR_PTR(-ENOENT);
>
> after the loop to be
>
> if (!pd->pwrdm_name)
> ...
>
> Could you revise this and resend?
>
> thanks
>
Good catch, looks like this was already merged into the omap-pm branch :/
Sending a followup patch fine with everyone?
>
> - Paul
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-08-12 17:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-11 2:00 [PATCH] omap: pm: Fix overflow when doing powerdomain deps lookups Mike Chan
2009-08-11 14:38 ` Kevin Hilman
2009-08-11 18:11 ` Mike Chan
2009-08-12 0:14 ` Kevin Hilman
2009-08-12 6:32 ` Paul Walmsley
2009-08-12 17:58 ` Mike Chan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox