Message ID | 1554307455-40361-3-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 |
> @@ -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
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; }
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(-)