lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1341439772-649-1-git-send-email-linus.walleij@linaro.org>
Date:	Thu,  5 Jul 2012 00:09:32 +0200
From:	Linus Walleij <linus.walleij@...aro.org>
To:	Mike Turquette <mturquette@...com>,
	Mike Turquette <mturquette@...aro.org>
Cc:	linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
	Linus Walleij <linus.walleij@...aro.org>, stable@...nel.org,
	Mike Turquette <mturquette@...aro.org>,
	Ulf Hansson <ulf.hansson@...ricsson.com>
Subject: [PATCH] clk: allow clocks without parents to change rate

The clk_change_rate() code would dereference clk->parent
to get clk->parent->rate without first checking that clk->parent
was valid. This doesn't work if the clock is (A) a root clock
and (B) can change rate. Such is the case with a VCO clock
like the ICST which consequently crash like this without
this patch:

Unable to handle kernel NULL pointer dereference at virtual address 0000001c
pgd = c0004000
[0000001c] *pgd=00000000
Internal error: Oops: 5 [#1] PREEMPT ARM
Modules linked in:
CPU: 0    Not tainted  (3.5.0-rc3-00003-g8156866-dirty #193)
PC is at clk_change_rate+0x34/0xd8
LR is at clk_change_rate+0x18/0xd8

Cc: stable@...nel.org
Cc: Mike Turquette <mturquette@...aro.org>
Cc: Ulf Hansson <ulf.hansson@...ricsson.com>
Signed-off-by: Linus Walleij <linus.walleij@...aro.org>
---
 drivers/clk/clk.c |   22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 687b00d..032d79c 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -854,14 +854,22 @@ static void clk_change_rate(struct clk *clk)
 
 	old_rate = clk->rate;
 
-	if (clk->ops->set_rate)
-		clk->ops->set_rate(clk->hw, clk->new_rate, clk->parent->rate);
+	if (clk->ops->set_rate) {
+		if (clk->parent)
+			clk->ops->set_rate(clk->hw, clk->new_rate,
+					clk->parent->rate);
+		else
+			clk->ops->set_rate(clk->hw, clk->new_rate, 0);
+	}
 
-	if (clk->ops->recalc_rate)
-		clk->rate = clk->ops->recalc_rate(clk->hw,
-				clk->parent->rate);
-	else
-		clk->rate = clk->parent->rate;
+	if (clk->ops->recalc_rate) {
+		if (clk->parent)
+			clk->rate = clk->ops->recalc_rate(clk->hw,
+							clk->parent->rate);
+		else
+			clk->rate = clk->ops->recalc_rate(clk->hw, 0);
+	} else
+		clk->rate = clk->parent ? clk->parent->rate : 0;
 
 	if (clk->notifier_count && old_rate != clk->rate)
 		__clk_notify(clk, POST_RATE_CHANGE, old_rate, clk->rate);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ