lkml.org 
[lkml]   [2016]   [Oct]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] PM / Domains: check for negative return from of_count_phandle_with_args
Date
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);

\
 
 \ /
  Last update: 2016-10-25 20:15    [W:0.052 / U:0.188 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site