]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/tegra: dc: Fix device node reference leak in tegra_dc_has_output()
authorFelix Gu <ustc.gu@gmail.com>
Tue, 27 Jan 2026 16:43:10 +0000 (00:43 +0800)
committerThierry Reding <treding@nvidia.com>
Thu, 28 May 2026 15:19:30 +0000 (17:19 +0200)
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>
Acked-by: Mikko Perttunen <mperttunen@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Link: https://patch.msgid.link/20260128-dc-v1-1-a88205826301@gmail.com
drivers/gpu/drm/tegra/dc.c

index 445be1b2d3c57d4cd965c721f1d48ee0e16faff0..3842ca34a16eb45ed4b1b8d89d412e902597a36c 100644 (file)
@@ -198,8 +198,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;
 }