From: Colin Ian King Date: Sat, 16 Apr 2016 12:50:03 +0000 (+0100) Subject: PM / clk: ensure we don't allocate a -ve size of count clks X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0b26985a7d76645598d98fec6922ddd1ec8cbc55;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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: Colin Ian King Acked-by: Pavel Machek Signed-off-by: Rafael J. Wysocki --- diff --git a/drivers/base/power/clock_ops.c b/drivers/base/power/clock_ops.c index 0e64a1b5e62a..3657ac1cb801 100644 --- a/drivers/base/power/clock_ops.c +++ b/drivers/base/power/clock_ops.c @@ -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);