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

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

PM / clk: ensure we don't allocate a -ve size of count clks



It is entirely possible for of_count_phandle_wit_args to
return a -ve error return value so we need to check for this
otherwise we end up allocating a negative number of clk objects.

Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Acked-by: default avatarPavel Machek <pavel@ucw.cz>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 02da2d72
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -159,7 +159,7 @@ int of_pm_clk_add_clks(struct device *dev)

	count = of_count_phandle_with_args(dev->of_node, "clocks",
					   "#clock-cells");
	if (count == 0)
	if (count <= 0)
		return -ENODEV;

	clks = kcalloc(count, sizeof(*clks), GFP_KERNEL);