* [PATCH] PM / clk: ensure we don't allocate a -ve size of count clks
@ 2016-04-16 12:50 Colin King
2016-04-16 12:52 ` Pavel Machek
2016-04-27 21:36 ` Rafael J. Wysocki
0 siblings, 2 replies; 4+ messages in thread
From: Colin King @ 2016-04-16 12:50 UTC (permalink / raw)
To: Rafael J . Wysocki, Pavel Machek, Len Brown, linux-pm; +Cc: linux-kernel
From: Colin Ian King <colin.king@canonical.com>
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>
---
drivers/base/power/clock_ops.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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;
clks = kcalloc(count, sizeof(*clks), GFP_KERNEL);
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] PM / clk: ensure we don't allocate a -ve size of count clks
2016-04-16 12:50 [PATCH] PM / clk: ensure we don't allocate a -ve size of count clks Colin King
@ 2016-04-16 12:52 ` Pavel Machek
2016-04-16 13:49 ` Colin Ian King
2016-04-27 21:36 ` Rafael J. Wysocki
1 sibling, 1 reply; 4+ messages in thread
From: Pavel Machek @ 2016-04-16 12:52 UTC (permalink / raw)
To: Colin King; +Cc: Rafael J . Wysocki, Len Brown, linux-pm, linux-kernel
On Sat 2016-04-16 13:50:03, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> 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>
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PM / clk: ensure we don't allocate a -ve size of count clks
2016-04-16 12:52 ` Pavel Machek
@ 2016-04-16 13:49 ` Colin Ian King
0 siblings, 0 replies; 4+ messages in thread
From: Colin Ian King @ 2016-04-16 13:49 UTC (permalink / raw)
To: Pavel Machek; +Cc: Rafael J . Wysocki, Len Brown, linux-pm, linux-kernel
On 16/04/16 13:52, Pavel Machek wrote:
> On Sat 2016-04-16 13:50:03, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> 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>
>
>
>> 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?
I don't think it will contribute much more than the current return.
>
> Pavel
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] PM / clk: ensure we don't allocate a -ve size of count clks
2016-04-16 12:50 [PATCH] PM / clk: ensure we don't allocate a -ve size of count clks Colin King
2016-04-16 12:52 ` Pavel Machek
@ 2016-04-27 21:36 ` Rafael J. Wysocki
1 sibling, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2016-04-27 21:36 UTC (permalink / raw)
To: Colin King
Cc: Rafael J . Wysocki, Pavel Machek, Len Brown, linux-pm, linux-kernel
On Saturday, April 16, 2016 01:50:03 PM Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> 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>
Applied, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-04-27 21:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-16 12:50 [PATCH] PM / clk: ensure we don't allocate a -ve size of count clks Colin King
2016-04-16 12:52 ` Pavel Machek
2016-04-16 13:49 ` Colin Ian King
2016-04-27 21:36 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).