diff mbox

[v2,1/3] clk: Don't dereference parent clock if is NULL

Message ID 1423749510-14525-2-git-send-email-javier.martinez@collabora.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Javier Martinez Canillas Feb. 12, 2015, 1:58 p.m. UTC
The clock passed as an argument to clk_mux_determine_rate_flags()
has the CLK_SET_RATE_PARENT flag set but it has no parent, then a
NULL pointer will tried to be dereferenced.

This shouldn't happen since setting that flag for a clock with no
parent is a bug but the core should be robust to handle that case.

Fixes: 035a61c314eb3 ("clk: Make clk API return per-user struct clk instances")
Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
---

Changes since v2:
 - Pass NULL struct clk_hw argument to __clk_determine_rate() if parent is NULL.
   suggested by Stephen Boyd.
---
 drivers/clk/clk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Stephen Boyd Feb. 12, 2015, 7 p.m. UTC | #1
On 02/12/15 05:58, Javier Martinez Canillas wrote:
> The clock passed as an argument to clk_mux_determine_rate_flags()
> has the CLK_SET_RATE_PARENT flag set but it has no parent, then a
> NULL pointer will tried to be dereferenced.
>
> This shouldn't happen since setting that flag for a clock with no
> parent is a bug but the core should be robust to handle that case.
>
> Fixes: 035a61c314eb3 ("clk: Make clk API return per-user struct clk instances")
> Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>

Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
diff mbox

Patch

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 7f53166af5e6..5941af7b4665 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -800,8 +800,8 @@  clk_mux_determine_rate_flags(struct clk_hw *hw, unsigned long rate,
 	if (core->flags & CLK_SET_RATE_NO_REPARENT) {
 		parent = core->parent;
 		if (core->flags & CLK_SET_RATE_PARENT)
-			best = __clk_determine_rate(parent->hw, rate,
-						    min_rate, max_rate);
+			best = __clk_determine_rate(parent ? parent->hw : NULL,
+						    rate, min_rate, max_rate);
 		else if (parent)
 			best = clk_core_get_rate_nolock(parent);
 		else