* [PATCH v2] drm/meson: fix possible object reference leak
@ 2019-04-08 2:58 Wen Yang
2019-04-08 9:13 ` Markus Elfring
0 siblings, 1 reply; 2+ messages in thread
From: Wen Yang @ 2019-04-08 2:58 UTC (permalink / raw)
To: linux-kernel
Cc: wang.yi59, Neil Armstrong, David Airlie, Kevin Hilman, dri-devel,
Markus Elfring, 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
Cc: Markus Elfring <Markus.Elfring@web.de>
---
v2->v1: convert a if statement into a ternary statement.
drivers/gpu/drm/meson/meson_dw_hdmi.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c
index 563953e..826b98b 100644
--- a/drivers/gpu/drm/meson/meson_dw_hdmi.c
+++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c
@@ -720,15 +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);
- return false;
+ return remote ? true : false;
}
static int meson_dw_hdmi_bind(struct device *dev, struct device *master,
--
2.9.5
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] drm/meson: fix possible object reference leak
2019-04-08 2:58 [PATCH v2] drm/meson: fix possible object reference leak Wen Yang
@ 2019-04-08 9:13 ` Markus Elfring
0 siblings, 0 replies; 2+ messages in thread
From: Markus Elfring @ 2019-04-08 9:13 UTC (permalink / raw)
To: Wen Yang, dri-devel, linux-amlogic, linux-arm-kernel
Cc: Yi Wang, Neil Armstrong, David Airlie, Kevin Hilman,
linux-kernel, Daniel Vetter
> v2->v1: convert a if statement into a ternary statement.
Would you like to omit the arrow in such version information?
> @@ -720,15 +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);
Can a reordering of the passed variables be useful for such function calls?
+ of_node_put(remote);
+ of_node_put(ep);
Regards,
Markus
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-04-08 9:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-08 2:58 [PATCH v2] drm/meson: fix possible object reference leak Wen Yang
2019-04-08 9:13 ` 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).