]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/tegra: rgb: Fix the unbound reference count
authorBiju Das <biju.das.jz@bp.renesas.com>
Wed, 5 Feb 2025 11:21:35 +0000 (11:21 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Jun 2025 10:04:02 +0000 (11:04 +0100)
[ Upstream commit 3c3642335065c3bde0742b0edc505b6ea8fdc2b3 ]

The of_get_child_by_name() increments the refcount in tegra_dc_rgb_probe,
but the driver does not decrement the refcount during unbind. Fix the
unbound reference count using devm_add_action_or_reset() helper.

Fixes: d8f4a9eda006 ("drm: Add NVIDIA Tegra20 support")
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Link: https://lore.kernel.org/r/20250205112137.36055-1-biju.das.jz@bp.renesas.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/tegra/rgb.c

index 4142a56ca764485dc13bfbe3134cba96d66f8432..a3052f645c4736dafbd660a6543a1e0cbd2ea53c 100644 (file)
@@ -170,6 +170,11 @@ static const struct drm_encoder_helper_funcs tegra_rgb_encoder_helper_funcs = {
        .atomic_check = tegra_rgb_encoder_atomic_check,
 };
 
+static void tegra_dc_of_node_put(void *data)
+{
+       of_node_put(data);
+}
+
 int tegra_dc_rgb_probe(struct tegra_dc *dc)
 {
        struct device_node *np;
@@ -177,7 +182,14 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc)
        int err;
 
        np = of_get_child_by_name(dc->dev->of_node, "rgb");
-       if (!np || !of_device_is_available(np))
+       if (!np)
+               return -ENODEV;
+
+       err = devm_add_action_or_reset(dc->dev, tegra_dc_of_node_put, np);
+       if (err < 0)
+               return err;
+
+       if (!of_device_is_available(np))
                return -ENODEV;
 
        rgb = devm_kzalloc(dc->dev, sizeof(*rgb), GFP_KERNEL);