Message ID | 20220607110841.53889-1-linmq006@gmail.com (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers | show |
Series | drm/msm/mdp4: Fix refcount leak in mdp4_modeset_init_intf | expand |
On Tue, 7 Jun 2022 at 14:08, Miaoqian Lin <linmq006@gmail.com> wrote: > > 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. > > Fixes: 86418f90a4c1 ("drm: convert drivers to use of_graph_get_remote_node") > Signed-off-by: Miaoqian Lin <linmq006@gmail.com> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Quoting Miaoqian Lin (2022-06-07 04:08:38) > 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. > > Fixes: 86418f90a4c1 ("drm: convert drivers to use of_graph_get_remote_node") > Signed-off-by: Miaoqian Lin <linmq006@gmail.com> > --- Reviewed-by: Stephen Boyd <swboyd@chromium.org>
On 6/7/2022 4:08 AM, Miaoqian Lin wrote: > 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. > > Fixes: 86418f90a4c1 ("drm: convert drivers to use of_graph_get_remote_node") > Signed-off-by: Miaoqian Lin <linmq006@gmail.com> > --- > 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? > diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c > index fb48c8c19ec3..17cb1fc78379 100644 > --- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c > +++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c > @@ -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 On 2022/6/11 7:20, Abhinav Kumar wrote: > > > On 6/7/2022 4:08 AM, Miaoqian Lin wrote: >> 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. >> >> Fixes: 86418f90a4c1 ("drm: convert drivers to use of_graph_get_remote_node") >> Signed-off-by: Miaoqian Lin <linmq006@gmail.com> >> --- >> 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. > 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. > Am i missing something? > >> diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c >> index fb48c8c19ec3..17cb1fc78379 100644 >> --- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c >> +++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c >> @@ -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); >> } >>
On 14/06/2022 13:07, Miaoqian Lin wrote: > Hi, Abhinav > > On 2022/6/11 7:20, Abhinav Kumar wrote: >> >> >> On 6/7/2022 4:08 AM, Miaoqian Lin wrote: >>> 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. >>> >>> Fixes: 86418f90a4c1 ("drm: convert drivers to use of_graph_get_remote_node") >>> Signed-off-by: Miaoqian Lin <linmq006@gmail.com> >>> --- >>> 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. >> > 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. 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. > >> Am i missing something? >> >>> diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c >>> index fb48c8c19ec3..17cb1fc78379 100644 >>> --- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c >>> +++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c >>> @@ -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); >>> } >>>
On 6/14/2022 3:09 AM, Dmitry Baryshkov wrote: > On 14/06/2022 13:07, Miaoqian Lin wrote: >> Hi, Abhinav >> >> On 2022/6/11 7:20, Abhinav Kumar wrote: >>> >>> >>> On 6/7/2022 4:08 AM, Miaoqian Lin wrote: >>>> 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. >>>> >>>> Fixes: 86418f90a4c1 ("drm: convert drivers to use >>>> of_graph_get_remote_node") >>>> Signed-off-by: Miaoqian Lin <linmq006@gmail.com> >>>> --- >>>> 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. >>> >> 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. > > 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, Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com> Will pick it up for -fixes. >> >>> Am i missing something? >>> >>>> diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c >>>> b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c >>>> index fb48c8c19ec3..17cb1fc78379 100644 >>>> --- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c >>>> +++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c >>>> @@ -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); >>>> } > >
diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c index fb48c8c19ec3..17cb1fc78379 100644 --- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c +++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c @@ -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); }
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. Fixes: 86418f90a4c1 ("drm: convert drivers to use of_graph_get_remote_node") Signed-off-by: Miaoqian Lin <linmq006@gmail.com> --- drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c | 2 ++ 1 file changed, 2 insertions(+)