Skip to content

Commit

Permalink
PM / clk: ensure we don't allocate a -ve size of count clks
Browse files Browse the repository at this point in the history
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 <colin.king@canonical.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Colin Ian King authored and Rafael J. Wysocki committed Apr 26, 2016
1 parent 02da2d7 commit 0b26985
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/base/power/clock_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0b26985

Please sign in to comment.