linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: ti: Call of_node_get() before of_find_xxx() API
@ 2022-09-15  3:11 Liang He
  2022-10-01  0:11 ` Stephen Boyd
  0 siblings, 1 reply; 2+ messages in thread
From: Liang He @ 2022-09-15  3:11 UTC (permalink / raw)
  To: mturquette, sboyd, kristo, linux-clk, linux-omap, windhl

In ti_find_clock_provider(), we need to call of_node_get() for
of_find_node_by_name() which will automatically call of_node_put()
for the 'from' argument.

Fixes: 51f661ef9a10 ("clk: ti: Add ti_find_clock_provider() to use clock-output-names")
Signed-off-by: Liang He <windhl@126.com>
---
 drivers/clk/ti/clk.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c
index 373e9438b57a..7c390cd67e1a 100644
--- a/drivers/clk/ti/clk.c
+++ b/drivers/clk/ti/clk.c
@@ -147,6 +147,7 @@ static struct device_node *ti_find_clock_provider(struct device_node *from,
 		return np;
 
 	/* Fall back to using old node name base provider name */
+	of_node_get(from);
 	return of_find_node_by_name(from, name);
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] clk: ti: Call of_node_get() before of_find_xxx() API
  2022-09-15  3:11 [PATCH] clk: ti: Call of_node_get() before of_find_xxx() API Liang He
@ 2022-10-01  0:11 ` Stephen Boyd
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Boyd @ 2022-10-01  0:11 UTC (permalink / raw)
  To: kristo, linux-clk, linux-omap, mturquette, windhl

Quoting Liang He (2022-09-14 20:11:21)
> In ti_find_clock_provider(), we need to call of_node_get() for
> of_find_node_by_name() which will automatically call of_node_put()
> for the 'from' argument.
> 
> Fixes: 51f661ef9a10 ("clk: ti: Add ti_find_clock_provider() to use clock-output-names")
> Signed-off-by: Liang He <windhl@126.com>
> ---
>  drivers/clk/ti/clk.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c
> index 373e9438b57a..7c390cd67e1a 100644
> --- a/drivers/clk/ti/clk.c
> +++ b/drivers/clk/ti/clk.c
> @@ -147,6 +147,7 @@ static struct device_node *ti_find_clock_provider(struct device_node *from,
>                 return np;
>  
>         /* Fall back to using old node name base provider name */
> +       of_node_get(from);

It seems better to hold the reference from the earlier search.

>         return of_find_node_by_name(from, name);
>  }

How about this?

----8<----
diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c
index ef2a445c63a3..a99279265e40 100644
--- a/drivers/clk/ti/clk.c
+++ b/drivers/clk/ti/clk.c
@@ -139,11 +139,12 @@ static struct device_node *ti_find_clock_provider(struct device_node *from,
 			break;
 		}
 	}
-	of_node_put(from);
 	kfree(tmp);
 
-	if (found)
+	if (found) {
+		of_node_put(from);
 		return np;
+	}
 
 	/* Fall back to using old node name base provider name */
 	return of_find_node_by_name(from, name);

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-01  0:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-15  3:11 [PATCH] clk: ti: Call of_node_get() before of_find_xxx() API Liang He
2022-10-01  0:11 ` Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).