Skip to contentSkip to conversation

soc/tegra: pmc: fix child-node lookup

PATCH Applied Johan Hovold 3 participants 7 messages Nov 15, 2017 – Aug 14, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 soc/tegra: pmc: fix child-node lookup

Fix child-node lookup during probe, which ended up searching the whole device tree depth-first starting at the parent rather than just matching on its children.

To make things worse, the parent pmc node could end up being prematurely freed as of_find_node_by_name() drops a reference to its first argument.

Fixes 3568df3d31d6 ("soc: tegra: Add thermal reset (thermtrip) support to PMC")
Cc stable <[email protected]> # 4.0
Cc Mikko Perttunen <[email protected]>
---
 drivers/soc/tegra/pmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/tegra/pmc.c +1 -1
index 0453ff6839a7..7e9ef3431bea 100644
@@ -1321,7 +1321,7 @@ static void tegra_pmc_init_tsense_reset(struct tegra_pmc *pmc)
 	if (!pmc->soc->has_tsense_reset)
 		return;
 
-	np = of_find_node_by_name(pmc->dev->of_node, "i2c-thermtrip");
+	np = of_get_child_by_name(pmc->dev->of_node, "i2c-thermtrip");
 	if (!np) {
 		dev_warn(dev, "i2c-thermtrip node not found, %s.\n", disabled);
 		return;
Signature · 1 line
2.15.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 21 lines · Johan Hovold

Fix child-node lookup during probe, which ended up searching the whole device tree depth-first starting at the parent rather than just matching on its children.

To make things worse, the parent pmc node could end up being prematurely freed as of_find_node_by_name() drops a reference to its first argument.

Fixes 3568df3d31d6 ("soc: tegra: Add thermal reset (thermtrip) support to PMC")
Cc stable <[email protected]> # 4.0
Cc Mikko Perttunen <[email protected]>
---
 drivers/soc/tegra/pmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/tegra/pmc.c +0 -0
index 0453ff6839a7..7e9ef3431bea 100644

drivers/soc/tegra/pmc.c static void tegra_pmc_init_tsense_reset(struct tegra_pmc *pmc) · line 1327

Quoted 8 lines
drivers/soc/tegra/pmc.c +1 -1
@@ -1321,7 +1321,7 @@ static void tegra_pmc_init_tsense_reset(struct tegra_pmc *pmc)
 	if (!pmc->soc->has_tsense_reset)
 		return;
 
-	np = of_find_node_by_name(pmc->dev->of_node, "i2c-thermtrip");
+	np = of_get_child_by_name(pmc->dev->of_node, "i2c-thermtrip");
 	if (!np) {
 		dev_warn(dev, "i2c-thermtrip node not found, %s.\n", disabled);
 		return;

Good find!

#2 lore raw
Quoted 33 lines · Mikko Perttunen
Quoted 21 lines · Johan Hovold

Fix child-node lookup during probe, which ended up searching the whole device tree depth-first starting at the parent rather than just matching on its children.

To make things worse, the parent pmc node could end up being prematurely freed as of_find_node_by_name() drops a reference to its first argument.

Fixes 3568df3d31d6 ("soc: tegra: Add thermal reset (thermtrip) support to PMC")
Cc stable <[email protected]> # 4.0
Cc Mikko Perttunen <[email protected]>
---
 drivers/soc/tegra/pmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/tegra/pmc.c +0 -0
index 0453ff6839a7..7e9ef3431bea 100644

drivers/soc/tegra/pmc.c static void tegra_pmc_init_tsense_reset(struct tegra_pmc *pmc) · line 1327

Quoted 8 lines
drivers/soc/tegra/pmc.c +1 -1
@@ -1321,7 +1321,7 @@ static void tegra_pmc_init_tsense_reset(struct tegra_pmc *pmc)
 	if (!pmc->soc->has_tsense_reset)
 		return;
 
-	np = of_find_node_by_name(pmc->dev->of_node, "i2c-thermtrip");
+	np = of_get_child_by_name(pmc->dev->of_node, "i2c-thermtrip");
 	if (!np) {
 		dev_warn(dev, "i2c-thermtrip node not found, %s.\n", disabled);
 		return;

Good find!

Quoted 1 line

This one still hasn't made it to linux-next so figured I'd send a reminder. Will you be picking this one up for 4.16, Thierry?

Thanks,
Johan

#3 lore raw
Quoted 34 lines · Johan Hovold
Quoted 33 lines · Mikko Perttunen
Quoted 21 lines · Johan Hovold

Fix child-node lookup during probe, which ended up searching the whole device tree depth-first starting at the parent rather than just matching on its children.

To make things worse, the parent pmc node could end up being prematurely freed as of_find_node_by_name() drops a reference to its first argument.

Fixes 3568df3d31d6 ("soc: tegra: Add thermal reset (thermtrip) support to PMC")
Cc stable <[email protected]> # 4.0
Cc Mikko Perttunen <[email protected]>
---
 drivers/soc/tegra/pmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/tegra/pmc.c +0 -0
index 0453ff6839a7..7e9ef3431bea 100644

drivers/soc/tegra/pmc.c static void tegra_pmc_init_tsense_reset(struct tegra_pmc *pmc) · line 1327

Quoted 8 lines
drivers/soc/tegra/pmc.c +1 -1
@@ -1321,7 +1321,7 @@ static void tegra_pmc_init_tsense_reset(struct tegra_pmc *pmc)
 	if (!pmc->soc->has_tsense_reset)
 		return;
 
-	np = of_find_node_by_name(pmc->dev->of_node, "i2c-thermtrip");
+	np = of_get_child_by_name(pmc->dev->of_node, "i2c-thermtrip");
 	if (!np) {
 		dev_warn(dev, "i2c-thermtrip node not found, %s.\n", disabled);
 		return;

Good find!

Quoted 4 lines
Quoted 1 line

This one still hasn't made it to linux-next so figured I'd send a reminder. Will you be picking this one up for 4.16, Thierry?

Another two months, another reminder; Thierry, can you pick this fix up? It's got Mikko's ack.

Mikko, can you please ping Thierry in case I'm getting stuck in his spam filter or something?

Thanks,
Johan

#4 lore raw
In reply to Johan Hovold
Quoted 7 lines · Johan Hovold

Fix child-node lookup during probe, which ended up searching the whole device tree depth-first starting at the parent rather than just matching on its children.

To make things worse, the parent pmc node could end up being prematurely freed as of_find_node_by_name() drops a reference to its first argument.

Quoted 7 lines
Fixes 3568df3d31d6 ("soc: tegra: Add thermal reset (thermtrip) support to PMC")
Cc stable <[email protected]> # 4.0
Cc Mikko Perttunen <[email protected]>
---
 drivers/soc/tegra/pmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

Thierry

#5 lore raw

Hi Thierry,

Quoted 16 lines · Thierry Reding
Quoted 7 lines · Johan Hovold

Fix child-node lookup during probe, which ended up searching the whole device tree depth-first starting at the parent rather than just matching on its children.

To make things worse, the parent pmc node could end up being prematurely freed as of_find_node_by_name() drops a reference to its first argument.

Quoted 7 lines
Fixes 3568df3d31d6 ("soc: tegra: Add thermal reset (thermtrip) support to PMC")
Cc stable <[email protected]> # 4.0
Cc Mikko Perttunen <[email protected]>
---
 drivers/soc/tegra/pmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 1 line

Applied, thanks.

I noticed this one still hasn't made it into linux-next. Looks like it wasn't included in you 4.17 pull request and is still sitting in the tegra for-4.17/soc branch.

Johan

#6 lore raw
Quoted 19 lines · Johan Hovold

Hi Thierry,

Quoted 16 lines · Thierry Reding
Quoted 14 lines · Johan Hovold

Fix child-node lookup during probe, which ended up searching the whole device tree depth-first starting at the parent rather than just matching on its children.

To make things worse, the parent pmc node could end up being prematurely freed as of_find_node_by_name() drops a reference to its first argument.

Fixes 3568df3d31d6 ("soc: tegra: Add thermal reset (thermtrip) support to PMC")
Cc stable <[email protected]> # 4.0
Cc Mikko Perttunen <[email protected]>
---
 drivers/soc/tegra/pmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 5 lines
Quoted 1 line

Applied, thanks.

I noticed this one still hasn't made it into linux-next. Looks like it wasn't included in you 4.17 pull request and is still sitting in the tegra for-4.17/soc branch.

Indeed. Looking at my tree it seems like I applied this to for-4.17/soc a couple of days after the signed tag for the pull request. It probably should've gone into a for-4.18/soc, or perhaps into fixes pull request.

I've cherry-picked it into for-4.20/soc now. Thanks for the reminder.

Thierry