From 0c106e57dea709395b5b5eb004987b7ddad251ad Mon Sep 17 00:00:00 2001 From: Tuomas Tynkkynen Date: Sat, 29 Jul 2017 02:58:43 +0300 Subject: [PATCH] soc/tegra: Fix bad of_node_put() in powergate init The for_each_child_of_node macro itself maintains the correct reference count of the nodes so the explicit of_node_put() call causes a warning: [ 0.098960] OF: ERROR: Bad of_node_put() on /pmc@7000e400/powergates/xusba [ 0.098981] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.11.3 #1-NixOS [ 0.098996] Hardware name: NVIDIA Jetson TX1 Developer Kit (DT) [ 0.099011] Call trace: [ 0.099034] [] dump_backtrace+0x0/0x2a0 [ 0.099051] [] show_stack+0x24/0x30 [ 0.099069] [] dump_stack+0x9c/0xc0 [ 0.099090] [] of_node_release+0xa4/0xa8 [ 0.099107] [] kobject_put+0x90/0x1f8 [ 0.099124] [] of_node_put+0x24/0x30 [ 0.099140] [] __of_get_next_child+0x4c/0x70 [ 0.099155] [] of_get_next_child+0x40/0x68 [ 0.099173] [] tegra_pmc_early_init+0x4e8/0x5ac [ 0.099189] [] do_one_initcall+0x5c/0x168 [ 0.099206] [] kernel_init_freeable+0xd4/0x240 [ 0.099224] [] kernel_init+0x18/0x108 [ 0.099238] [] ret_from_fork+0x10/0x50 (It's not very apparent from the OF documentation that of_node_put() is not needed; the macro itself has no docstring and of_get_next_child() used in the implementation begins with "Returns a node pointer with refcount incremented" but then only at the very end of the docstring the crucial part "Decrements the refcount of prev" is mentioned.) Fixes: a38045121bf42 ("soc/tegra: pmc: Add generic PM domain support") Signed-off-by: Tuomas Tynkkynen Signed-off-by: Thierry Reding --- drivers/soc/tegra/pmc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c index e233dd5dcab3..0453ff6839a7 100644 --- a/drivers/soc/tegra/pmc.c +++ b/drivers/soc/tegra/pmc.c @@ -918,10 +918,8 @@ static void tegra_powergate_init(struct tegra_pmc *pmc, if (!np) return; - for_each_child_of_node(np, child) { + for_each_child_of_node(np, child) tegra_powergate_add(pmc, child); - of_node_put(child); - } of_node_put(np); }