fpga: stratix10-soc: fix wrong of_node_put() in init function
diff mbox series

Message ID 20181203122145.1534-1-nsaenzjulienne@suse.de
State New, archived
Headers show
Series
  • fpga: stratix10-soc: fix wrong of_node_put() in init function
Related show

Commit Message

Nicolas Saenz Julienne Dec. 3, 2018, 12:21 p.m. UTC
After finding a "firmware" dt node stratix10 tries to match it's
compatible string with it. To do so it's calling of_find_matching_node()
which already takes care of decreasing the refcount on the "firmware"
node. We are then incorrectly decreasing the refcount on that node
again.

This patch removes the unwarranted call to of_node_put().

Fixes: e7eef1d7633a ("fpga: add intel stratix10 soc fpga manager driver")
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---
 drivers/fpga/stratix10-soc.c | 2 --
 1 file changed, 2 deletions(-)

Comments

Alan Tull Dec. 3, 2018, 4:12 p.m. UTC | #1
On Mon, Dec 3, 2018 at 6:22 AM Nicolas Saenz Julienne
<nsaenzjulienne@suse.de> wrote:

Hi Nicolas,

Thanks for catching this!  I'll fix up one formatting thing (below).

>
> After finding a "firmware" dt node stratix10 tries to match it's
> compatible string with it. To do so it's calling of_find_matching_node()
> which already takes care of decreasing the refcount on the "firmware"
> node. We are then incorrectly decreasing the refcount on that node
> again.
>
> This patch removes the unwarranted call to of_node_put().
>
> Fixes: e7eef1d7633a ("fpga: add intel stratix10 soc fpga manager driver")
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Acked-by: Alan Tull <atull@kernel.org>

> ---
>  drivers/fpga/stratix10-soc.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/drivers/fpga/stratix10-soc.c b/drivers/fpga/stratix10-soc.c
> index a1a09e04fab8..e75dbe583152 100644
> --- a/drivers/fpga/stratix10-soc.c
> +++ b/drivers/fpga/stratix10-soc.c
> @@ -509,13 +509,11 @@ static int __init s10_init(void)
>
>         np = of_find_matching_node(fw_np, s10_of_match);
>         if (!np) {
> -               of_node_put(fw_np);
>                 return -ENODEV;
>         }

We don't need the brackets anymore around the return statement.  I'll fix it up.

Thanks,
Alan

>
>         of_node_put(np);
>         ret = of_platform_populate(fw_np, s10_of_match, NULL, NULL);
> -       of_node_put(fw_np);
>         if (ret)
>                 return ret;
>
> --
> 2.19.2
>
Moritz Fischer Dec. 3, 2018, 5:01 p.m. UTC | #2
Hi Nicolas,

good catch.

On Mon, Dec 3, 2018 at 8:13 AM Alan Tull <atull@kernel.org> wrote:
>
> On Mon, Dec 3, 2018 at 6:22 AM Nicolas Saenz Julienne
> <nsaenzjulienne@suse.de> wrote:
>
> Hi Nicolas,
>
> Thanks for catching this!  I'll fix up one formatting thing (below).
>
> >
> > After finding a "firmware" dt node stratix10 tries to match it's
> > compatible string with it. To do so it's calling of_find_matching_node()
> > which already takes care of decreasing the refcount on the "firmware"
> > node. We are then incorrectly decreasing the refcount on that node
> > again.
> >
> > This patch removes the unwarranted call to of_node_put().
> >
> > Fixes: e7eef1d7633a ("fpga: add intel stratix10 soc fpga manager driver")
> > Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Acked-by: Alan Tull <atull@kernel.org>
Acked-by: Moritz Fischer <mdf@kernel.org>
>
> > ---
> >  drivers/fpga/stratix10-soc.c | 2 --
> >  1 file changed, 2 deletions(-)
> >
> > diff --git a/drivers/fpga/stratix10-soc.c b/drivers/fpga/stratix10-soc.c
> > index a1a09e04fab8..e75dbe583152 100644
> > --- a/drivers/fpga/stratix10-soc.c
> > +++ b/drivers/fpga/stratix10-soc.c
> > @@ -509,13 +509,11 @@ static int __init s10_init(void)
> >
> >         np = of_find_matching_node(fw_np, s10_of_match);
> >         if (!np) {
> > -               of_node_put(fw_np);
> >                 return -ENODEV;
> >         }
>
> We don't need the brackets anymore around the return statement.  I'll fix it up.
>
> Thanks,
> Alan
>
> >
> >         of_node_put(np);
> >         ret = of_platform_populate(fw_np, s10_of_match, NULL, NULL);
> > -       of_node_put(fw_np);
> >         if (ret)
> >                 return ret;
> >
> > --
> > 2.19.2
> >

Thanks,
Moritz

Patch
diff mbox series

diff --git a/drivers/fpga/stratix10-soc.c b/drivers/fpga/stratix10-soc.c
index a1a09e04fab8..e75dbe583152 100644
--- a/drivers/fpga/stratix10-soc.c
+++ b/drivers/fpga/stratix10-soc.c
@@ -509,13 +509,11 @@  static int __init s10_init(void)
 
 	np = of_find_matching_node(fw_np, s10_of_match);
 	if (!np) {
-		of_node_put(fw_np);
 		return -ENODEV;
 	}
 
 	of_node_put(np);
 	ret = of_platform_populate(fw_np, s10_of_match, NULL, NULL);
-	of_node_put(fw_np);
 	if (ret)
 		return ret;