Skip to contentSkip to conversation

media: mtk-mdp: fix reference count on old device tree

PATCH In review Matthias Brugger 3 participants 4 messages Jun 21, 2019 – Jul 12, 2019

Subsystems (3)
lore
Share & tools
lore

Matthias Brugger

author maintainer
#0 lore raw

PATCH 1/1 media: mtk-mdp: fix reference count on old device tree

of_get_next_child() increments the reference count of the returning device_node. Decrement it in the check if we are using the old or the new DTB.

Fixes ba1f1f70c2c0 ("[media] media: mtk-mdp: Fix mdp device tree")
---
 drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/platform/mtk-mdp/mtk_mdp_core.c +3 -1
index bbb24fb95b95..bafe53c5d54a 100644
@@ -118,7 +118,9 @@ static int mtk_mdp_probe(struct platform_device *pdev)
 	mutex_init(&mdp->vpulock);
 
 	/* Old dts had the components as child nodes */
-	if (of_get_next_child(dev->of_node, NULL)) {
+	parent = of_get_next_child(dev->of_node, NULL);
+	if (parent) {
+		of_node_put(parent);
 		parent = dev->of_node;
 		dev_warn(dev, "device tree is out of date\n");
 	} else {
Signature · 1 line
2.21.0
maintainer
#1 lore raw
Quoted 9 lines · Matthias Brugger

of_get_next_child() increments the reference count of the returning device_node. Decrement it in the check if we are using the old or the new DTB.

Fixes ba1f1f70c2c0 ("[media] media: mtk-mdp: Fix mdp device tree")
---
 drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

<formletter>

This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

author maintainer
#2 lore raw
In reply to Matthias Brugger
Quoted 6 lines · Matthias Brugger

of_get_next_child() increments the reference count of the returning device_node. Decrement it in the check if we are using the old or the new DTB.

Fixes ba1f1f70c2c0 ("[media] media: mtk-mdp: Fix mdp device tree")

Any comments on that?

Quoted 20 lines
---
 drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/platform/mtk-mdp/mtk_mdp_core.c +3 -1
index bbb24fb95b95..bafe53c5d54a 100644
@@ -118,7 +118,9 @@ static int mtk_mdp_probe(struct platform_device *pdev)
 	mutex_init(&mdp->vpulock);
 
 	/* Old dts had the components as child nodes */
-	if (of_get_next_child(dev->of_node, NULL)) {
+	parent = of_get_next_child(dev->of_node, NULL);
+	if (parent) {
+		of_node_put(parent);
 		parent = dev->of_node;
 		dev_warn(dev, "device tree is out of date\n");
 	} else {
Acked-by
#3 lore raw
Quoted 11 lines · Matthias Brugger
Quoted 6 lines · Matthias Brugger

of_get_next_child() increments the reference count of the returning device_node. Decrement it in the check if we are using the old or the new DTB.

Fixes ba1f1f70c2c0 ("[media] media: mtk-mdp: Fix mdp device tree")

Any comments on that?

Hi Matthias,
Thanks for fixing the bug. Sorry to reply late~

Quoted 20 lines
Quoted 20 lines
---
 drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/platform/mtk-mdp/mtk_mdp_core.c +3 -1
index bbb24fb95b95..bafe53c5d54a 100644
@@ -118,7 +118,9 @@ static int mtk_mdp_probe(struct platform_device *pdev)
 	mutex_init(&mdp->vpulock);
 
 	/* Old dts had the components as child nodes */
-	if (of_get_next_child(dev->of_node, NULL)) {
+	parent = of_get_next_child(dev->of_node, NULL);
+	if (parent) {
+		of_node_put(parent);
 		parent = dev->of_node;
 		dev_warn(dev, "device tree is out of date\n");
 	} else {