Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a1fee00d authored by Colin Ian King's avatar Colin Ian King Committed by Rafael J. Wysocki
Browse files

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: default avatarColin Ian King <colin.king@canonical.com>
Acked-by: default avatarKevin Hilman <khilman@baylibre.com>
Acked-by: default avatarPavel Machek <pavel@ucw.cz>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 411bf2a8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);