Skip to content

Commit 3c36423

Browse files
bijudasthierryreding
authored andcommitted
drm/tegra: rgb: Fix the unbound reference count
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: d8f4a9e ("drm: Add NVIDIA Tegra20 support") Signed-off-by: Biju Das <[email protected]> Signed-off-by: Thierry Reding <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 33ca5aa commit 3c36423

File tree

1 file changed

+13
-1
lines changed
  • drivers/gpu/drm/tegra

1 file changed

+13
-1
lines changed

drivers/gpu/drm/tegra/rgb.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,26 @@ static const struct drm_encoder_helper_funcs tegra_rgb_encoder_helper_funcs = {
200200
.atomic_check = tegra_rgb_encoder_atomic_check,
201201
};
202202

203+
static void tegra_dc_of_node_put(void *data)
204+
{
205+
of_node_put(data);
206+
}
207+
203208
int tegra_dc_rgb_probe(struct tegra_dc *dc)
204209
{
205210
struct device_node *np;
206211
struct tegra_rgb *rgb;
207212
int err;
208213

209214
np = of_get_child_by_name(dc->dev->of_node, "rgb");
210-
if (!np || !of_device_is_available(np))
215+
if (!np)
216+
return -ENODEV;
217+
218+
err = devm_add_action_or_reset(dc->dev, tegra_dc_of_node_put, np);
219+
if (err < 0)
220+
return err;
221+
222+
if (!of_device_is_available(np))
211223
return -ENODEV;
212224

213225
rgb = devm_kzalloc(dc->dev, sizeof(*rgb), GFP_KERNEL);

0 commit comments

Comments
 (0)