* [PATCH] PM / Domains: check for negative return from of_count_phandle_with_args
@ 2016-10-25 16:33 Colin King
2016-10-25 18:14 ` Kevin Hilman
0 siblings, 1 reply; 4+ messages in thread
From: Colin King @ 2016-10-25 16:33 UTC (permalink / raw)
To: Rafael J . Wysocki, Kevin Hilman, Ulf Hansson, Pavel Machek,
Len Brown, Greg Kroah-Hartman, linux-pm
Cc: linux-kernel
From: Colin Ian King <colin.king@canonical.com>
The return from of_count_phandle_with_args can be negative, so we
should avoid kcalloc of a negative count of genpd_power_stat structs
by sanity checking if count is zero or less.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/base/power/domain.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index aac656a..661737c 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -2113,7 +2113,7 @@ int of_genpd_parse_idle_states(struct device_node *dn,
struct of_phandle_iterator it;
count = of_count_phandle_with_args(dn, "domain-idle-states", NULL);
- if (!count)
+ if (count <= 0)
return -EINVAL;
st = kcalloc(count, sizeof(*st), GFP_KERNEL);
--
2.9.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] PM / Domains: check for negative return from of_count_phandle_with_args
2016-10-25 16:33 [PATCH] PM / Domains: check for negative return from of_count_phandle_with_args Colin King
@ 2016-10-25 18:14 ` Kevin Hilman
2016-10-26 11:00 ` Pavel Machek
0 siblings, 1 reply; 4+ messages in thread
From: Kevin Hilman @ 2016-10-25 18:14 UTC (permalink / raw)
To: Colin King
Cc: Rafael J . Wysocki, Ulf Hansson, Pavel Machek, Len Brown,
Greg Kroah-Hartman, linux-pm, linux-kernel
Colin King <colin.king@canonical.com> writes:
> From: Colin Ian King <colin.king@canonical.com>
>
> The return from of_count_phandle_with_args can be negative, so we
> should avoid kcalloc of a negative count of genpd_power_stat structs
> by sanity checking if count is zero or less.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Kevin Hilman <khilman@baylibre.com>
> ---
> drivers/base/power/domain.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index aac656a..661737c 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -2113,7 +2113,7 @@ int of_genpd_parse_idle_states(struct device_node *dn,
> struct of_phandle_iterator it;
>
> count = of_count_phandle_with_args(dn, "domain-idle-states", NULL);
> - if (!count)
> + if (count <= 0)
> return -EINVAL;
>
> st = kcalloc(count, sizeof(*st), GFP_KERNEL);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PM / Domains: check for negative return from of_count_phandle_with_args
2016-10-25 18:14 ` Kevin Hilman
@ 2016-10-26 11:00 ` Pavel Machek
2016-11-01 4:48 ` Rafael J. Wysocki
0 siblings, 1 reply; 4+ messages in thread
From: Pavel Machek @ 2016-10-26 11:00 UTC (permalink / raw)
To: Kevin Hilman
Cc: Colin King, Rafael J . Wysocki, Ulf Hansson, Len Brown,
Greg Kroah-Hartman, linux-pm, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 657 bytes --]
On Tue 2016-10-25 11:14:40, Kevin Hilman wrote:
> Colin King <colin.king@canonical.com> writes:
>
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > The return from of_count_phandle_with_args can be negative, so we
> > should avoid kcalloc of a negative count of genpd_power_stat structs
> > by sanity checking if count is zero or less.
> >
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
>
> Acked-by: Kevin Hilman <khilman@baylibre.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PM / Domains: check for negative return from of_count_phandle_with_args
2016-10-26 11:00 ` Pavel Machek
@ 2016-11-01 4:48 ` Rafael J. Wysocki
0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2016-11-01 4:48 UTC (permalink / raw)
To: Pavel Machek, Colin King
Cc: Kevin Hilman, Ulf Hansson, Len Brown, Greg Kroah-Hartman,
linux-pm, linux-kernel
On Wednesday, October 26, 2016 01:00:08 PM Pavel Machek wrote:
>
> --zhXaljGHf11kAtnf
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: inline
> Content-Transfer-Encoding: quoted-printable
>
> On Tue 2016-10-25 11:14:40, Kevin Hilman wrote:
> > Colin King <colin.king@canonical.com> writes:
> >=20
> > > From: Colin Ian King <colin.king@canonical.com>
> > >
> > > The return from of_count_phandle_with_args can be negative, so we
> > > should avoid kcalloc of a negative count of genpd_power_stat structs
> > > by sanity checking if count is zero or less.
> > >
> > > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> >=20
> > Acked-by: Kevin Hilman <khilman@baylibre.com>
>
> Acked-by: Pavel Machek <pavel@ucw.cz>
Applied, thanks!
Rafael
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-11-01 4:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-25 16:33 [PATCH] PM / Domains: check for negative return from of_count_phandle_with_args Colin King
2016-10-25 18:14 ` Kevin Hilman
2016-10-26 11:00 ` Pavel Machek
2016-11-01 4:48 ` Rafael J. Wysocki
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.