Linux Tegra architecture development
 help / color / mirror / Atom feed
* [PATCH] drm/tegra: dc: Fix device node reference leak in tegra_dc_has_output()
@ 2026-01-27 16:43 Felix Gu
  2026-02-06  3:53 ` Mikko Perttunen
  2026-05-28 14:20 ` Thierry Reding
  0 siblings, 2 replies; 3+ messages in thread
From: Felix Gu @ 2026-01-27 16:43 UTC (permalink / raw)
  To: Thierry Reding, Mikko Perttunen, David Airlie, Simona Vetter,
	Jonathan Hunter
  Cc: Thierry Reding, dri-devel, linux-tegra, linux-kernel, Felix Gu

The of_for_each_phandle() macro increments the reference count of the
device node it iterates over. If the loop exits early, the reference must
be released manually.

In tegra_dc_has_output(), the function returns true immediately when a
match is found, failing to release the current node's reference.

Fix this by adding a call to of_node_put() before returning from the loop.

Fixes: c57997bce423 ("drm/tegra: sor: Add Tegra186 support")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
 drivers/gpu/drm/tegra/dc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index 01e9d5011dd8..9bf6c008a5ea 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -101,8 +101,10 @@ bool tegra_dc_has_output(struct tegra_dc *dc, struct device *dev)
 	int err;
 
 	of_for_each_phandle(&it, err, np, "nvidia,outputs", NULL, 0)
-		if (it.node == dev->of_node)
+		if (it.node == dev->of_node) {
+			of_node_put(it.node);
 			return true;
+		}
 
 	return false;
 }

---
base-commit: 615aad0f61e0c7a898184a394dc895c610100d4f
change-id: 20260127-dc-e396ab5384da

Best regards,
-- 
Felix Gu <ustc.gu@gmail.com>


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

* Re: [PATCH] drm/tegra: dc: Fix device node reference leak in tegra_dc_has_output()
  2026-01-27 16:43 [PATCH] drm/tegra: dc: Fix device node reference leak in tegra_dc_has_output() Felix Gu
@ 2026-02-06  3:53 ` Mikko Perttunen
  2026-05-28 14:20 ` Thierry Reding
  1 sibling, 0 replies; 3+ messages in thread
From: Mikko Perttunen @ 2026-02-06  3:53 UTC (permalink / raw)
  To: Thierry Reding, David Airlie, Simona Vetter, Jonathan Hunter,
	Felix Gu
  Cc: Thierry Reding, dri-devel, linux-tegra, linux-kernel, Felix Gu

On Wednesday, January 28, 2026 1:43 AM Felix Gu wrote:
> The of_for_each_phandle() macro increments the reference count of the
> device node it iterates over. If the loop exits early, the reference must
> be released manually.
> 
> In tegra_dc_has_output(), the function returns true immediately when a
> match is found, failing to release the current node's reference.
> 
> Fix this by adding a call to of_node_put() before returning from the loop.
> 
> Fixes: c57997bce423 ("drm/tegra: sor: Add Tegra186 support")
> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
> ---
>  drivers/gpu/drm/tegra/dc.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
> index 01e9d5011dd8..9bf6c008a5ea 100644
> --- a/drivers/gpu/drm/tegra/dc.c
> +++ b/drivers/gpu/drm/tegra/dc.c
> @@ -101,8 +101,10 @@ bool tegra_dc_has_output(struct tegra_dc *dc, struct device *dev)
>  	int err;
>  
>  	of_for_each_phandle(&it, err, np, "nvidia,outputs", NULL, 0)
> -		if (it.node == dev->of_node)
> +		if (it.node == dev->of_node) {
> +			of_node_put(it.node);
>  			return true;
> +		}
>  
>  	return false;
>  }
> 
> ---
> base-commit: 615aad0f61e0c7a898184a394dc895c610100d4f
> change-id: 20260127-dc-e396ab5384da
> 
> Best regards,
> -- 
> Felix Gu <ustc.gu@gmail.com>
> 
> 

Acked-by: Mikko Perttunen <mperttunen@nvidia.com>




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

* Re: [PATCH] drm/tegra: dc: Fix device node reference leak in tegra_dc_has_output()
  2026-01-27 16:43 [PATCH] drm/tegra: dc: Fix device node reference leak in tegra_dc_has_output() Felix Gu
  2026-02-06  3:53 ` Mikko Perttunen
@ 2026-05-28 14:20 ` Thierry Reding
  1 sibling, 0 replies; 3+ messages in thread
From: Thierry Reding @ 2026-05-28 14:20 UTC (permalink / raw)
  To: Felix Gu
  Cc: Thierry Reding, Mikko Perttunen, David Airlie, Simona Vetter,
	Jonathan Hunter, Thierry Reding, dri-devel, linux-tegra,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 742 bytes --]

On Wed, Jan 28, 2026 at 12:43:10AM +0800, Felix Gu wrote:
> The of_for_each_phandle() macro increments the reference count of the
> device node it iterates over. If the loop exits early, the reference must
> be released manually.
> 
> In tegra_dc_has_output(), the function returns true immediately when a
> match is found, failing to release the current node's reference.
> 
> Fix this by adding a call to of_node_put() before returning from the loop.
> 
> Fixes: c57997bce423 ("drm/tegra: sor: Add Tegra186 support")
> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
> ---
>  drivers/gpu/drm/tegra/dc.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Sorry for missing this earlier. Applied now, thanks.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2026-05-28 14:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-27 16:43 [PATCH] drm/tegra: dc: Fix device node reference leak in tegra_dc_has_output() Felix Gu
2026-02-06  3:53 ` Mikko Perttunen
2026-05-28 14:20 ` Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox