From: Colin Ian King Date: Tue, 25 Oct 2016 16:33:27 +0000 (+0100) Subject: PM / Domains: check for negative return from of_count_phandle_with_args() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=a1fee00dc95644e0590b4f1a3755c9f6b1243b3a;p=linux.git PM / Domains: check for negative return from of_count_phandle_with_args() 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 Acked-by: Kevin Hilman Acked-by: Pavel Machek Signed-off-by: Rafael J. Wysocki --- diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index aac656a889dc0..661737c2bae0b 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);