drm/msm/mdp4: Fix refcount leak in mdp4_modeset_init_intf
PATCH 1/1 drm/msm/mdp4: Fix refcount leak in mdp4_modeset_init_intf
of_graph_get_remote_node() returns remote device node pointer with refcount incremented, we should use of_node_put() on it when not need anymore.
Add missing of_node_put() to avoid refcount leak.
--- drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c +2 -0
@@ -216,6 +216,7 @@ static int mdp4_modeset_init_intf(struct mdp4_kms *mdp4_kms, encoder =mdp4_lcdc_encoder_init (dev, panel_node);if (IS_ERR (encoder)) {DRM_DEV_ERROR (dev->dev,"failed to construct LCDC encoder\n" ); +of_node_put (panel_node);return PTR_ERR (encoder); }
@@ -225,6 +226,7 @@ static int mdp4_modeset_init_intf(struct mdp4_kms *mdp4_kms, connector =mdp4_lvds_connector_init (dev, panel_node, encoder);if (IS_ERR (connector)) {DRM_DEV_ERROR (dev->dev,"failed to initialize LVDS connector\n" ); +of_node_put (panel_node);return PTR_ERR (connector); }
Signature · 1 line
2.25.1
Quoted 8 lines · Miaoqian Lin
of_graph_get_remote_node()returns remote device node pointer with refcount incremented, we should useof_node_put()on it when not need anymore.
Add missingof_node_put()to avoid refcount leak.Fixes 86418f90a4c1 ("drm: convert drivers to use of_graph_get_remote_node")Signed-off-by Miaoqian Lin <[email protected]>
Signature · 2 lines
With best wishes Dmitry
Quoting Miaoqian Lin (2022-06-07 04:08:38)
Quoted 8 lines
of_graph_get_remote_node()returns remote device node pointer with refcount incremented, we should useof_node_put()on it when not need anymore.
Add missingof_node_put()to avoid refcount leak.Fixes 86418f90a4c1 ("drm: convert drivers to use of_graph_get_remote_node")Signed-off-by Miaoqian Lin <[email protected]>---
Quoted 11 lines · Miaoqian Lin
of_graph_get_remote_node()returns remote device node pointer with refcount incremented, we should useof_node_put()on it when not need anymore.
Add missingof_node_put()to avoid refcount leak.Fixes 86418f90a4c1 ("drm: convert drivers to use of_graph_get_remote_node")Signed-off-by Miaoqian Lin <[email protected]>--- drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c | 2 ++ 1 file changed, 2 insertions(+)
This patch itself looks fine and will cover the cases when there was an error and we did not release the refcount.
But, even in the normal cases I am not finding where we are releasing the refcount for the panel_node.
I dont see a of_node_put() on mdp4_lcdc_encoder->panel_node.
Am i missing something?
Quoted 20 lines
drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c +2
-0@@ -216,6 +216,7 @@ static int mdp4_modeset_init_intf(struct mdp4_kms *mdp4_kms, encoder =mdp4_lcdc_encoder_init (dev, panel_node);if (IS_ERR (encoder)) {DRM_DEV_ERROR (dev->dev,"failed to construct LCDC encoder\n" ); +of_node_put (panel_node);return PTR_ERR (encoder); }@@ -225,6 +226,7 @@ static int mdp4_modeset_init_intf(struct mdp4_kms *mdp4_kms, connector =mdp4_lvds_connector_init (dev, panel_node, encoder);if (IS_ERR (connector)) {DRM_DEV_ERROR (dev->dev,"failed to initialize LVDS connector\n" ); +of_node_put (panel_node);return PTR_ERR (connector); }
Hi, Abhinav
Quoted 15 lines · Abhinav Kumar
Quoted 11 lines · Miaoqian Lin
of_graph_get_remote_node()returns remote device node pointer with refcount incremented, we should useof_node_put()on it when not need anymore.
Add missingof_node_put()to avoid refcount leak.Fixes 86418f90a4c1 ("drm: convert drivers to use of_graph_get_remote_node")Signed-off-by Miaoqian Lin <[email protected]>---
drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c| 2 ++1 file changed, 2 insertions(+)
Quoted 6 lines
This patch itself looks fine and will cover the cases when there was an error and we did not release the refcount.
But, even in the normal cases I am not finding where we are releasing the refcount for the
panel_node.I dont see a
of_node_put()onmdp4_lcdc_encoder->panel_node.
Thanks for your review.
I don't see it either. It's a bit messy because the reference assigned to mdp4_lcdc_encoder->panel_node and mdp4_lvds_connector->panel_node both.
Quoted 21 lines
Am i missing something?
Quoted 19 lines
drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c +1
-0@@ -216,6 +216,7 @@ static int mdp4_modeset_init_intf(struct mdp4_kms *mdp4_kms, encoder = mdp4_lcdc_encoder_init(dev, panel_node); if (IS_ERR(encoder)) { DRM_DEV_ERROR(dev->dev, "failed to construct LCDC encoder\n"); + of_node_put(panel_node); return PTR_ERR(encoder); } @@ -225,6 +226,7 @@ static int mdp4_modeset_init_intf(struct mdp4_kms *mdp4_kms,connector =
mdp4_lvds_connector_init(dev, panel_node, encoder); if (IS_ERR(connector)) {
DRM_DEV_ERROR(dev->dev, "failed to initialize LVDS connector\n"); +of_node_put(panel_node);
returnPTR_ERR(connector);
}
Quoted 20 lines · Miaoqian Lin
Hi, Abhinav
Quoted 17 lines · Abhinav Kumar
Quoted 11 lines · Miaoqian Lin
of_graph_get_remote_node()returns remote device node pointer with refcount incremented, we should useof_node_put()on it when not need anymore.
Add missingof_node_put()to avoid refcount leak.Fixes 86418f90a4c1 ("drm: convert drivers to use of_graph_get_remote_node")Signed-off-by Miaoqian Lin <[email protected]>--- drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c | 2 ++ 1 file changed, 2 insertions(+)This patch itself looks fine and will cover the cases when there was an error and we did not release the refcount.
Quoted 7 lines
Quoted 4 lines
But, even in the normal cases I am not finding where we are releasing the refcount for the
panel_node.I dont see a
of_node_put()onmdp4_lcdc_encoder->panel_node.Thanks for your review.
I don't see it either. It's a bit messy because the reference assigned to
mdp4_lcdc_encoder->panel_nodeandmdp4_lvds_connector->panel_nodeboth.
I have a plan to rework mdp4 lcdc support once I get my ifc6410 lvds cable. Thus I think we can land this patch now and fix the mdp4 lcdc/lvds code leaking the reference in the due time.
Quoted 22 lines
Quoted 22 lines
Am i missing something?
Quoted 19 lines
drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c +1
-0@@ -216,6 +216,7 @@ static int mdp4_modeset_init_intf(struct mdp4_kms *mdp4_kms, encoder = mdp4_lcdc_encoder_init(dev, panel_node); if (IS_ERR(encoder)) { DRM_DEV_ERROR(dev->dev, "failed to construct LCDC encoder\n"); + of_node_put(panel_node); return PTR_ERR(encoder); } @@ -225,6 +226,7 @@ static int mdp4_modeset_init_intf(struct mdp4_kms *mdp4_kms,connector =
mdp4_lvds_connector_init(dev, panel_node, encoder); if (IS_ERR(connector)) {
DRM_DEV_ERROR(dev->dev, "failed to initialize LVDS connector\n");
+of_node_put(panel_node);
returnPTR_ERR(connector);
}
Signature · 2 lines
With best wishes Dmitry
Abhinav Kumar
Reviewed-byQuoted 23 lines · Dmitry Baryshkov
Quoted 22 lines · Miaoqian Lin
Hi, Abhinav
Quoted 19 lines · Abhinav Kumar
Quoted 11 lines · Miaoqian Lin
of_graph_get_remote_node()returns remote device node pointer with refcount incremented, we should useof_node_put()on it when not need anymore.
Add missingof_node_put()to avoid refcount leak.Fixes 86418f90a4c1 ("drm: convert drivers to use of_graph_get_remote_node")Signed-off-by Miaoqian Lin <[email protected]>---
drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c| 2 ++1 file changed, 2 insertions(+)This patch itself looks fine and will cover the cases when there was an error and we did not release the refcount.
But, even in the normal cases I am not finding where we are releasing the refcount for the
panel_node.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
I dont see a
of_node_put()onmdp4_lcdc_encoder->panel_node.Thanks for your review.
I don't see it either. It's a bit messy because the reference assigned to
mdp4_lcdc_encoder->panel_nodeandmdp4_lvds_connector->panel_nodeboth.I have a plan to rework mdp4 lcdc support once I get my ifc6410 lvds cable. Thus I think we can land this patch now and fix the mdp4 lcdc/lvds code leaking the reference in the due time.
Alright, with that assurance,
Will pick it up for -fixes.
Quoted 24 lines
Quoted 22 lines
Quoted 22 lines
Am i missing something?
Quoted 19 lines
drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c +1
-0@@ -216,6 +216,7 @@ static int mdp4_modeset_init_intf(structmdp4_kms *mdp4_kms, encoder = mdp4_lcdc_encoder_init(dev, panel_node); if (IS_ERR(encoder)) { DRM_DEV_ERROR(dev->dev, "failed to construct LCDC encoder\n"); + of_node_put(panel_node); return PTR_ERR(encoder); }@@ -225,6 +226,7 @@ static int mdp4_modeset_init_intf(struct
mdp4_kms*mdp4_kms, connector =mdp4_lvds_connector_init(dev, panel_node, encoder); if (IS_ERR(connector)) {
DRM_DEV_ERROR(dev->dev, "failed to initialize LVDS connector\n"); +of_node_put(panel_node);
returnPTR_ERR(connector);
}