Message ID | 1554307455-40361-5-git-send-email-wen.yang99@zte.com.cn (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/7] drm/mediatek: fix possible object reference leak | expand |
Hello Wen, Thank you for the patch. On Thu, Apr 04, 2019 at 12:04:12AM +0800, Wen Yang wrote: > The call to of_find_matching_node 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/omapdrm/dss/omapdss-boot-init.c:212: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. > drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c:237:1-7: 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@zte.com.cn> > Cc: Tomi Valkeinen <tomi.valkeinen@ti.com> > Cc: David Airlie <airlied@linux.ie> > Cc: Daniel Vetter <daniel@ffwll.ch> > Cc: Sebastian Reichel <sebastian.reichel@collabora.com> > Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > Cc: dri-devel@lists.freedesktop.org > Cc: linux-kernel@vger.kernel.org Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Would you like to get the series merged in one go, or individual patches picked by the respective maintainer ? > --- > drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c b/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c > index 2b41c75..60067e8 100644 > --- a/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c > +++ b/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c > @@ -208,8 +208,10 @@ static int __init omapdss_boot_init(void) > > dss = of_find_matching_node(NULL, omapdss_of_match); > > - if (dss == NULL || !of_device_is_available(dss)) > + if (dss == NULL || !of_device_is_available(dss)) { > + of_node_put(dss); > return 0; > + } > > omapdss_walk_device(dss, true); > > @@ -234,6 +236,7 @@ static int __init omapdss_boot_init(void) > kfree(n); > } > > + of_node_put(dss); > return 0; > } >
> @@ -208,8 +208,10 @@ static int __init omapdss_boot_init(void) > > dss = of_find_matching_node(NULL, omapdss_of_match); > > - if (dss == NULL || !of_device_is_available(dss)) > + if (dss == NULL || !of_device_is_available(dss)) { > + of_node_put(dss); > return 0; > + } https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c?id=61de49cb596710b918f7a80839f0b6de2017bc32#n203 Can it be nicer to add a jump target here? + if (!dss || !of_device_is_available(dss)) - return 0; + goto put_node; > > omapdss_walk_device(dss, true); > > @@ -234,6 +236,7 @@ static int __init omapdss_boot_init(void) > kfree(n); > } > +put_node: > + of_node_put(dss); > return 0; > } Regards, Markus
> > The call to of_find_matching_node 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/omapdrm/dss/omapdss-boot-init.c:212: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. > > drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c:237:1-7: 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@zte.com.cn> > > Cc: Tomi Valkeinen <tomi.valkeinen@ti.com> > > Cc: David Airlie <airlied@linux.ie> > > Cc: Daniel Vetter <daniel@ffwll.ch> > > Cc: Sebastian Reichel <sebastian.reichel@collabora.com> > > Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > > Cc: dri-devel@lists.freedesktop.org > > Cc: linux-kernel@vger.kernel.org > > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > > Would you like to get the series merged in one go, or individual patches > picked by the respective maintainer ? Thank you. We are sorry that we did not respond in time because of the Ching Ming Festival holiday. In our opinion, both ways are fine. In addition, we just checked and found that some patches have been selected by the maintainers. -- Regards, Wen
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c b/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c index 2b41c75..60067e8 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c +++ b/drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c @@ -208,8 +208,10 @@ static int __init omapdss_boot_init(void) dss = of_find_matching_node(NULL, omapdss_of_match); - if (dss == NULL || !of_device_is_available(dss)) + if (dss == NULL || !of_device_is_available(dss)) { + of_node_put(dss); return 0; + } omapdss_walk_device(dss, true); @@ -234,6 +236,7 @@ static int __init omapdss_boot_init(void) kfree(n); } + of_node_put(dss); return 0; }
The call to of_find_matching_node 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/omapdrm/dss/omapdss-boot-init.c:212: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. drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c:237:1-7: 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@zte.com.cn> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com> Cc: David Airlie <airlied@linux.ie> Cc: Daniel Vetter <daniel@ffwll.ch> Cc: Sebastian Reichel <sebastian.reichel@collabora.com> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org --- drivers/gpu/drm/omapdrm/dss/omapdss-boot-init.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)