summaryrefslogtreecommitdiff
path: root/drivers/base/power
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2016-10-25 17:33:27 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-10-27 13:00:32 +0200
commita1fee00dc95644e0590b4f1a3755c9f6b1243b3a (patch)
tree45cf5b081069f6cba6cde94dac3500face44b25e /drivers/base/power
parent411bf2a8db76d7ed6f710df77121e5113ee8fe64 (diff)
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 <colin.king@canonical.com> Acked-by: Kevin Hilman <khilman@baylibre.com> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/base/power')
-rw-r--r--drivers/base/power/domain.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index aac656a889dc..661737c2bae0 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);