Skip to contentSkip to conversation

drm/meson: encoder_cvbs: Fix refcount leak in meson_encoder_cvbs_init

PATCH Superseded Miaoqian Lin 2 participants 4 messages May 31, 2022

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/meson: encoder_cvbs: Fix refcount leak in meson_encoder_cvbs_init

of_graph_get_remote_node() returns remote device nodepointer with refcount incremented, we should use of_node_put() on it when done. Add missing of_node_put() to avoid refcount leak.

Fixes 318ba02cd8a8 ("drm/meson: encoder_cvbs: switch to bridge with ATTACH_NO_CONNECTOR")
---
 drivers/gpu/drm/meson/meson_encoder_cvbs.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/meson/meson_encoder_cvbs.c +1 -0
index fd8db97ba8ba..8110a6e39320 100644
@@ -238,6 +238,7 @@ int meson_encoder_cvbs_init(struct meson_drm *priv)
 	}
 
 	meson_encoder_cvbs->next_bridge = of_drm_find_bridge(remote);
+	of_node_put(remote);
 	if (!meson_encoder_cvbs->next_bridge) {
 		dev_err(priv->dev, "Failed to find CVBS Connector bridge\n");
 		return -EPROBE_DEFER;
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/2 drm/meson: encoder_hdmi: Fix refcount leak in meson_encoder_hdmi_init

of_graph_get_remote_node() returns remote device nodepointer with refcount incremented, we should use of_node_put() on it when done. Add missing of_node_put() to avoid refcount leak.

Fixes e67f6037ae1b ("drm/meson: split out encoder from meson_dw_hdmi")
---
 drivers/gpu/drm/meson/meson_encoder_hdmi.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/meson/meson_encoder_hdmi.c +1 -0
index 5e306de6f485..f3341458f8b7 100644
@@ -363,6 +363,7 @@ int meson_encoder_hdmi_init(struct meson_drm *priv)
 	}
 
 	meson_encoder_hdmi->next_bridge = of_drm_find_bridge(remote);
+	of_node_put(remote);
 	if (!meson_encoder_hdmi->next_bridge) {
 		dev_err(priv->dev, "Failed to find HDMI transceiver bridge\n");
 		return -EPROBE_DEFER;
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH 2/2] drm/meson: encoder_hdmi: Fix refcount leak in meson_encoder_hdmi_init

Hello,

first of all: thank you for spotting this and sending a patch!

On Tue, May 31, 2022 at 4:49 PM Miaoqian Lin <[email protected]> wrote:
[...]

drivers/gpu/drm/meson/meson_encoder_hdmi.c int meson_encoder_hdmi_init(struct meson_drm *priv) · line 366

Quoted 9 lines
drivers/gpu/drm/meson/meson_encoder_hdmi.c +1 -0
index 5e306de6f485..f3341458f8b7 100644
@@ -363,6 +363,7 @@ int meson_encoder_hdmi_init(struct meson_drm *priv)
        }
 
        meson_encoder_hdmi->next_bridge = of_drm_find_bridge(remote);
+       of_node_put(remote);

further down in the same function remote is used again:
pdev = of_find_device_by_node(remote);

My understanding is that we should only use of_node_put() once we don't need to access the node (in this case the variable is "remote") anymore.

Best regards,
Martin

reviewer Reviewed-by on v1 1/2
#3 lore raw
In reply to Miaoqian Lin
Quoted 7 lines · Miaoqian Lin

of_graph_get_remote_node() returns remote device nodepointer with refcount incremented, we should use of_node_put() on it when done. Add missing of_node_put() to avoid refcount leak.

Fixes 318ba02cd8a8 ("drm/meson: encoder_cvbs: switch to bridge with ATTACH_NO_CONNECTOR")