Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/meson: Fix refcount bugs in meson_vpu_has_available_connectors()

In this function, there are two refcount leak bugs:
(1) when breaking out of for_each_endpoint_of_node(), we need call
the of_node_put() for the 'ep';
(2) we should call of_node_put() for the reference returned by
of_graph_get_remote_port() when it is not used anymore.

Fixes: bbbe775ec5b5 ("drm: Add support for Amlogic Meson Graphic Controller")
Signed-off-by: Liang He <windhl@126.com>
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Acked-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220726010722.1319416-1-windhl@126.com

authored by

Liang He and committed by
Neil Armstrong
91b3c8db c20ee574

+4 -1
+4 -1
drivers/gpu/drm/meson/meson_drv.c
··· 115 115 for_each_endpoint_of_node(dev->of_node, ep) { 116 116 /* If the endpoint node exists, consider it enabled */ 117 117 remote = of_graph_get_remote_port(ep); 118 - if (remote) 118 + if (remote) { 119 + of_node_put(remote); 120 + of_node_put(ep); 119 121 return true; 122 + } 120 123 } 121 124 122 125 return false;