Re: [PATCH v2] drm: rcar-du: fix possible object reference leak
wen.yang99 at zte.com.cn
wen.yang99 at zte.com.cn
Mon Apr 8 09:23:47 UTC 2019
> > The call to of_get_parent returns a node pointer with refcount
> > incremented thus it must be explicitly decremented after the last
> > usage.
> >
> > Detected by coccinelle with the following warnings:
> > drivers/gpu/drm/rcar-du/rcar_du_of.c:235:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 216, but without a corresponding object release within this function.
> > drivers/gpu/drm/rcar-du/rcar_du_of.c:236:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 209, but without a corresponding object release within this function.
> >
> > Signed-off-by: Wen Yang <wen.yang99 at zte.com.cn>
> > Suggested-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> > Cc: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> > Cc: Kieran Bingham <kieran.bingham+renesas at ideasonboard.com>
> > Cc: David Airlie <airlied at linux.ie>
> > Cc: Daniel Vetter <daniel at ffwll.ch>
> > Cc: dri-devel at lists.freedesktop.org
> > Cc: linux-renesas-soc at vger.kernel.org
> > Cc: linux-kernel at vger.kernel.org (open list)
> > ---
> > v2->v1: turn the return into a goto done.
> >
> > drivers/gpu/drm/rcar-du/rcar_du_of.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/rcar-du/rcar_du_of.c b/drivers/gpu/drm/rcar-du/rcar_du_of.c
> > index afef696..782bfc7 100644
> > --- a/drivers/gpu/drm/rcar-du/rcar_du_of.c
> > +++ b/drivers/gpu/drm/rcar-du/rcar_du_of.c
> > @@ -232,7 +232,7 @@ static void __init rcar_du_of_lvds_patch(const struct of_device_id *of_ids)
> > lvds_node = of_find_compatible_node(NULL, NULL, compatible);
> > if (lvds_node) {
> > of_node_put(lvds_node);
> > - return;
> > + goto done;
> > }
> >
>
>
> you might have to create multiple level to do handling it.. there are
> unnecessary put being done on "done" which is not valid
>
> for this case.
Hi Mukesh,
Thank you for your comments.
lvds_data has been initialized to 0,
so the put operation in the done tag may have no effect:
199 struct lvds_of_data lvds_data[2] = { };
...
309 done:
310 for (i = 0; i < info->num_lvds; ++i) {
311 of_node_put(lvds_data[i].clkspec.np);
312 of_node_put(lvds_data[i].local);
313 of_node_put(lvds_data[i].remote);
314 }
315
316 of_node_put(soc_node);
317 of_node_put(du_node);
---
Thanks and regards,
Wen
More information about the dri-devel
mailing list