* [PATCH 1/7] drm/mediatek: fix possible object reference leak [not found] <1554307455-40361-1-git-send-email-wen.yang99@zte.com.cn> @ 2019-04-03 16:04 ` Wen Yang 2019-04-09 5:15 ` CK Hu 2019-04-03 16:04 ` [PATCH 2/7] drm/meson: " Wen Yang 1 sibling, 1 reply; 4+ messages in thread From: Wen Yang @ 2019-04-03 16:04 UTC (permalink / raw) To: linux-kernel Cc: wang.yi59, Philipp Zabel, David Airlie, dri-devel, Matthias Brugger, linux-mediatek, Daniel Vetter, CK Hu, Wen Yang, linux-arm-kernel The call to of_parse_phandle 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/mediatek/mtk_hdmi.c:1521:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1509, but without a corresponding object release within this function. drivers/gpu/drm/mediatek/mtk_hdmi.c:1524:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1509, but without a corresponding object release within this function. Signed-off-by: Wen Yang <wen.yang99@zte.com.cn> Cc: CK Hu <ck.hu@mediatek.com> Cc: Philipp Zabel <p.zabel@pengutronix.de> Cc: David Airlie <airlied@linux.ie> Cc: Daniel Vetter <daniel@ffwll.ch> Cc: Matthias Brugger <matthias.bgg@gmail.com> Cc: dri-devel@lists.freedesktop.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-mediatek@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- drivers/gpu/drm/mediatek/mtk_hdmi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c index 915cc84..ed10f4d 100644 --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c @@ -1516,6 +1516,7 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, of_node_put(remote); hdmi->ddc_adpt = of_find_i2c_adapter_by_node(i2c_np); + of_node_put(i2c_np); if (!hdmi->ddc_adpt) { dev_err(dev, "Failed to get ddc i2c adapter by node\n"); return -EINVAL; -- 2.9.5 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/7] drm/mediatek: fix possible object reference leak 2019-04-03 16:04 ` [PATCH 1/7] drm/mediatek: fix possible object reference leak Wen Yang @ 2019-04-09 5:15 ` CK Hu 0 siblings, 0 replies; 4+ messages in thread From: CK Hu @ 2019-04-09 5:15 UTC (permalink / raw) To: Wen Yang Cc: wang.yi59, Philipp Zabel, David Airlie, linux-kernel, dri-devel, linux-mediatek, Daniel Vetter, Matthias Brugger, linux-arm-kernel Hi, Wen: On Thu, 2019-04-04 at 00:04 +0800, Wen Yang wrote: > The call to of_parse_phandle 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/mediatek/mtk_hdmi.c:1521:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1509, but without a corresponding object release within this function. > drivers/gpu/drm/mediatek/mtk_hdmi.c:1524:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1509, but without a corresponding object release within this function. For this patch, applied to mediatek-drm-fixes-5.1 [1], thanks. [1] https://github.com/ckhu-mediatek/linux.git-tags/commits/mediatek-drm-fixes-5.1 Regards, CK > > Signed-off-by: Wen Yang <wen.yang99@zte.com.cn> > Cc: CK Hu <ck.hu@mediatek.com> > Cc: Philipp Zabel <p.zabel@pengutronix.de> > Cc: David Airlie <airlied@linux.ie> > Cc: Daniel Vetter <daniel@ffwll.ch> > Cc: Matthias Brugger <matthias.bgg@gmail.com> > Cc: dri-devel@lists.freedesktop.org > Cc: linux-arm-kernel@lists.infradead.org > Cc: linux-mediatek@lists.infradead.org > Cc: linux-kernel@vger.kernel.org > --- > drivers/gpu/drm/mediatek/mtk_hdmi.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c > index 915cc84..ed10f4d 100644 > --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c > +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c > @@ -1516,6 +1516,7 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, > of_node_put(remote); > > hdmi->ddc_adpt = of_find_i2c_adapter_by_node(i2c_np); > + of_node_put(i2c_np); > if (!hdmi->ddc_adpt) { > dev_err(dev, "Failed to get ddc i2c adapter by node\n"); > return -EINVAL; _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/7] drm/meson: fix possible object reference leak [not found] <1554307455-40361-1-git-send-email-wen.yang99@zte.com.cn> 2019-04-03 16:04 ` [PATCH 1/7] drm/mediatek: fix possible object reference leak Wen Yang @ 2019-04-03 16:04 ` Wen Yang 2019-04-04 20:05 ` Markus Elfring 1 sibling, 1 reply; 4+ messages in thread From: Wen Yang @ 2019-04-03 16:04 UTC (permalink / raw) To: linux-kernel Cc: wang.yi59, Neil Armstrong, David Airlie, Kevin Hilman, dri-devel, Daniel Vetter, linux-amlogic, Wen Yang, linux-arm-kernel The call to of_graph_get_remote_port 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/meson/meson_dw_hdmi.c:725:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 722, but without a corresponding object release within this function. Signed-off-by: Wen Yang <wen.yang99@zte.com.cn> Cc: Neil Armstrong <narmstrong@baylibre.com> Cc: David Airlie <airlied@linux.ie> Cc: Daniel Vetter <daniel@ffwll.ch> Cc: Kevin Hilman <khilman@baylibre.com> Cc: dri-devel@lists.freedesktop.org Cc: linux-amlogic@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org (open list) --- drivers/gpu/drm/meson/meson_dw_hdmi.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c index 563953e..109a933 100644 --- a/drivers/gpu/drm/meson/meson_dw_hdmi.c +++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c @@ -720,13 +720,10 @@ static bool meson_hdmi_connector_is_available(struct device *dev) /* If the endpoint node exists, consider it enabled */ remote = of_graph_get_remote_port(ep); - if (remote) { - of_node_put(ep); - return true; - } - of_node_put(ep); of_node_put(remote); + if (remote) + return true; return false; } -- 2.9.5 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/7] drm/meson: fix possible object reference leak 2019-04-03 16:04 ` [PATCH 2/7] drm/meson: " Wen Yang @ 2019-04-04 20:05 ` Markus Elfring 0 siblings, 0 replies; 4+ messages in thread From: Markus Elfring @ 2019-04-04 20:05 UTC (permalink / raw) To: Wen Yang, dri-devel, kernel-janitors Cc: Yi Wang, Neil Armstrong, David Airlie, Kevin Hilman, linux-kernel, Daniel Vetter, linux-amlogic, linux-arm-kernel > @@ -720,13 +720,10 @@ static bool meson_hdmi_connector_is_available(struct device *dev) > > /* If the endpoint node exists, consider it enabled */ > remote = of_graph_get_remote_port(ep); > - if (remote) { > - of_node_put(ep); > - return true; > - } > - > of_node_put(ep); > of_node_put(remote); https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/gpu/drm/meson/meson_dw_hdmi.c?id=61de49cb596710b918f7a80839f0b6de2017bc32#n712 Can the order of these put calls matter (because of processor caches)? > + if (remote) > + return true; > > return false; Would the use of a ternary operator be more succinct here? + return remote ? true : false; Regards, Markus _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-04-09 5:16 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <1554307455-40361-1-git-send-email-wen.yang99@zte.com.cn> 2019-04-03 16:04 ` [PATCH 1/7] drm/mediatek: fix possible object reference leak Wen Yang 2019-04-09 5:15 ` CK Hu 2019-04-03 16:04 ` [PATCH 2/7] drm/meson: " Wen Yang 2019-04-04 20:05 ` Markus Elfring
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).