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

From: Pavel Machek
Date: Sat Apr 16 2016 - 08:52:41 EST


On Sat 2016-04-16 13:50:03, Colin King wrote:
> From: Colin Ian King <colin.king@xxxxxxxxxxxxx>
>
> 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@xxxxxxxxxxxxx>

Acked-by: Pavel Machek <pavel@xxxxxx>


> diff --git a/drivers/base/power/clock_ops.c b/drivers/base/power/clock_ops.c
> index 0e64a1b..3657ac1 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;

Would it make sense to propagate the error value?

Pavel

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html