LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 1/2] clk: Fix __clk_get access to already freed owner field.
@ 2015-02-05 18:24 Alban Browaeys
  2015-02-05 18:24 ` [PATCH 2/2] clk: Fix OOPS calling hlist_del on an already poisoned hlist Alban Browaeys
  2015-02-05 19:30 ` [PATCH 1/2] clk: Fix __clk_get access to already freed owner field Stephen Boyd
  0 siblings, 2 replies; 10+ messages in thread
From: Alban Browaeys @ 2015-02-05 18:24 UTC (permalink / raw)
  To: Tomeu Vizoso, Mike Turquette, Stephen Boyd; +Cc: linux-kernel, Alban Browaeys

On the second call to __set_clk_parents from of_clk_set_defaults, here
when registering the second fimc device the kernel OOPS in an "unhandled
paging request at virtual address 6b6b6b77". This in __clk_get when
dereferencing clk->owner.

Move the clk free in the kref managed _clk_release call instead of
plain __clk_put.

Fixes: 035a61c314eb ("clk: Make clk API return per-user struct clk
instances)

Signed-off-by: Alban Browaeys <prahal@yahoo.com>
---
 drivers/clk/clk.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index df94668..8f33722 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2485,15 +2485,18 @@ EXPORT_SYMBOL_GPL(clk_register);
  */
 static void __clk_release(struct kref *ref)
 {
-	struct clk_core *clk = container_of(ref, struct clk_core, ref);
-	int i = clk->num_parents;
+	struct clk_core *core = container_of(ref, struct clk_core, ref);
+	struct clk *clk = container_of(&core, struct clk, core);
+	int i = core->num_parents;
 
-	kfree(clk->parents);
+	kfree(core->parents);
 	while (--i >= 0)
-		kfree_const(clk->parent_names[i]);
+		kfree_const(core->parent_names[i]);
+
+	kfree(core->parent_names);
+	kfree_const(core->name);
+	kfree(core);
 
-	kfree(clk->parent_names);
-	kfree_const(clk->name);
 	kfree(clk);
 }
 
@@ -2671,8 +2674,6 @@ void __clk_put(struct clk *clk)
 	clk_prepare_unlock();
 
 	module_put(owner);
-
-	kfree(clk);
 }
 
 /***        clk rate change notifiers        ***/
-- 
2.1.4


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-02-06  9:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-05 18:24 [PATCH 1/2] clk: Fix __clk_get access to already freed owner field Alban Browaeys
2015-02-05 18:24 ` [PATCH 2/2] clk: Fix OOPS calling hlist_del on an already poisoned hlist Alban Browaeys
2015-02-05 19:33   ` Stephen Boyd
2015-02-05 20:56     ` Alban Browaeys
2015-02-05 19:30 ` [PATCH 1/2] clk: Fix __clk_get access to already freed owner field Stephen Boyd
2015-02-05 20:43   ` Alban Browaeys
2015-02-05 21:03     ` Stephen Boyd
2015-02-05 21:30       ` Alban Browaeys
2015-02-05 21:45         ` Stephen Boyd
2015-02-06  9:52           ` Alban Browaeys

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).