2019-06-21 11:34:09

by Matthias Brugger

[permalink] [raw]
Subject: [PATCH] [media] 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")
Signed-off-by: Matthias Brugger <[email protected]>
---
drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
index bbb24fb95b95..bafe53c5d54a 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
@@ -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 {
--
2.21.0


2019-06-21 13:23:04

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH] [media] media: mtk-mdp: fix reference count on old device tree

On Fri, Jun 21, 2019 at 01:32:50PM +0200, Matthias Brugger wrote:
> 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")
> Signed-off-by: Matthias Brugger <[email protected]>
> ---
> 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>

2019-07-08 13:04:14

by Matthias Brugger

[permalink] [raw]
Subject: Re: [PATCH] [media] media: mtk-mdp: fix reference count on old device tree



On 21/06/2019 13:32, Matthias Brugger wrote:
> 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")
> Signed-off-by: Matthias Brugger <[email protected]>

Any comments on that?

> ---
> drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
> index bbb24fb95b95..bafe53c5d54a 100644
> --- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
> +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
> @@ -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 {
>

2019-07-12 07:25:22

by houlong wei

[permalink] [raw]
Subject: Re: [PATCH] [media] media: mtk-mdp: fix reference count on old device tree



On Mon, 2019-07-08 at 17:06 +0800, Matthias Brugger wrote:
>
> On 21/06/2019 13:32, Matthias Brugger wrote:
> > 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")
> > Signed-off-by: Matthias Brugger <[email protected]>
>
> Any comments on that?
>

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

Acked-by: Houlong Wei <[email protected]>


> > ---
> > drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
> > index bbb24fb95b95..bafe53c5d54a 100644
> > --- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
> > +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
> > @@ -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 {
> >