drm/meson: Fix refcount leak
v2 cover drm/meson: Fix refcount leak
The following patchset fix two refcount leak bugs. The cause of the bugs are missing of_node_put() after of_graph_get_remote_node().
changes in v2:
- patch#2:Fixed patch in meson_encoder_hdmi_init, call of_node_put() after of_find_device_by_node() and error paths before that. noted by Martin Blumenstingl <[email protected]>
(patch#1: no changes since v1)
v1 link:
patch#1: https://lore.kernel.org/r/[email protected]/
patch#2: https://lore.kernel.org/r/[email protected]/
Miaoqian Lin (2):
drm/meson: encoder_cvbs: Fix refcount leak in meson_encoder_cvbs_init drm/meson: encoder_hdmi: Fix refcount leak in meson_encoder_hdmi_init
drivers/gpu/drm/meson/meson_encoder_cvbs.c | 1 + drivers/gpu/drm/meson/meson_encoder_hdmi.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-)
Signature · 1 line
2.25.1
PATCH v2 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.
--- drivers/gpu/drm/meson/meson_encoder_cvbs.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/meson/meson_encoder_cvbs.c +1 -0
@@ -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
Re: [PATCH v2 1/2] drm/meson: encoder_cvbs: Fix refcount leak in meson_encoder_cvbs_init
Hello,
thank you for your patch!
Quoted 7 lines · Miaoqian Lin
of_graph_get_remote_node()returns remote device nodepointer with refcount incremented, we should useof_node_put()on it when done. Add missingof_node_put()to avoid refcount leak.Fixes 318ba02cd8a8 ("drm/meson: encoder_cvbs: switch to bridge with ATTACH_NO_CONNECTOR")Signed-off-by Miaoqian Lin <[email protected]>
As far as I can tell this patch is identical to the one from v1. Please keep my Reviewed-by from the previous version in case nothing has changed for this specific patch:
Best regards,
Martin
PATCH v2 2/2 drm/meson: encoder_hdmi: Fix refcount leak in meson_encoder_hdmi_init
In reply to Miaoqian Linof_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.
---
changes in v2:
- call of_node_put() after of_find_device_by_node() and error paths before of_find_device_by_node();
--- drivers/gpu/drm/meson/meson_encoder_hdmi.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/gpu/drm/meson/meson_encoder_hdmi.c +11 -4
@@ -365,7 +365,8 @@ int meson_encoder_hdmi_init(struct meson_drm *priv) meson_encoder_hdmi->next_bridge =of_drm_find_bridge (remote);if (!meson_encoder_hdmi->next_bridge) {dev_err (priv->dev,"Failed to find HDMI transceiver bridge\n" ); -return -EPROBE_DEFER ; + ret = -EPROBE_DEFER ; + goto err_put_node; }/* HDMI Encoder Bridge */
@@ -383,7 +384,7 @@ int meson_encoder_hdmi_init(struct meson_drm *priv) DRM_MODE_ENCODER_TMDS);if (ret) {dev_err (priv->dev,"Failed to init HDMI encoder: %d\n" , ret); -return ret; + goto err_put_node; } meson_encoder_hdmi->encoder.possible_crtcs =BIT (0 );
@@ -393,7 +394,7 @@ int meson_encoder_hdmi_init(struct meson_drm *priv) DRM_BRIDGE_ATTACH_NO_CONNECTOR);if (ret) {dev_err (priv->dev,"Failed to attach bridge: %d\n" , ret); -return ret; + goto err_put_node; }/* Initialize & attach Bridge Connector */
@@ -401,7 +402,8 @@ int meson_encoder_hdmi_init(struct meson_drm *priv) &meson_encoder_hdmi->encoder);if (IS_ERR (meson_encoder_hdmi->connector)) {dev_err (priv->dev,"Unable to create HDMI bridge connector\n" ); -return PTR_ERR (meson_encoder_hdmi->connector); + ret =PTR_ERR (meson_encoder_hdmi->connector); + goto err_put_node; }drm_connector_attach_encoder (meson_encoder_hdmi->connector, &meson_encoder_hdmi->encoder);
@@ -428,6 +430,7 @@ int meson_encoder_hdmi_init(struct meson_drm *priv) meson_encoder_hdmi->connector->ycbcr_420_allowed = true; pdev =of_find_device_by_node (remote); +of_node_put (remote);if (pdev) {struct cec_connector_info conn_info;struct cec_notifier *notifier;
@@ -444,4 +447,8 @@ int meson_encoder_hdmi_init(struct meson_drm *priv)dev_dbg (priv->dev,"HDMI encoder initialized\n" );return 0 ; + +err_put_node: +of_node_put (remote); +return ret; }
Signature · 1 line
2.25.1
Re: [PATCH v2 2/2] drm/meson: encoder_hdmi: Fix refcount leak in meson_encoder_hdmi_init
Hello,
thank you for working on this!
Quoted 7 lines · Miaoqian Lin
of_graph_get_remote_node()returns remote device nodepointer with refcount incremented, we should useof_node_put()on it when done. Add missingof_node_put()to avoid refcount leak.Fixes e67f6037ae1b ("drm/meson: split out encoder from meson_dw_hdmi")Signed-off-by Miaoqian Lin <[email protected]>
Note to self: at first I thought the following code needs to be changed as well:
notifier = cec_notifier_conn_register(&pdev->dev, NULL, &conn_info); if (!notifier)
return -ENOMEM;
But a few lines before this we already have:of_node_put(remote);
Meaning: this patch is fine as is.
Best regards,
Martin
Neil Armstrong
AppliedHi,
Quoted 10 lines · Miaoqian Lin
The following patchset fix two refcount leak bugs. The cause of the bugs are missing
of_node_put()afterof_graph_get_remote_node().changes in v2:
- patch#2:Fixed patch inmeson_encoder_hdmi_init, callof_node_put()afterof_find_device_by_node()and error paths before that. noted by Martin Blumenstingl <[email protected]>[...]
Thanks, Applied to https://anongit.freedesktop.org/git/drm/drm-misc.git (drm-misc-next)
[1/2] drm/meson: encoder_cvbs: Fix refcount leak in meson_encoder_cvbs_init
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=7d255ddbbf679aa47e041cbf68520fd985ed2279 [2/2] drm/meson: encoder_hdmi: Fix refcount leak in meson_encoder_hdmi_init https://cgit.freedesktop.org/drm/drm-misc/commit/?id=d82a5a4aae9d0203234737caed1bf470aa317568
Signature · 1 line
Neil