]> git.itanic.dy.fi Git - linux-stable/commitdiff
drm/meson: Fix refcount bugs in meson_vpu_has_available_connectors()
authorLiang He <windhl@126.com>
Tue, 26 Jul 2022 01:07:22 +0000 (09:07 +0800)
committerNeil Armstrong <narmstrong@baylibre.com>
Mon, 8 Aug 2022 07:46:22 +0000 (09:46 +0200)
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
drivers/gpu/drm/meson/meson_drv.c

index 1b70938cfd2c43b327cc3df086a57a7efc8d07e4..bd4ca11d3ff536fbf8a297433dc35392cd560e7b 100644 (file)
@@ -115,8 +115,11 @@ static bool meson_vpu_has_available_connectors(struct device *dev)
        for_each_endpoint_of_node(dev->of_node, ep) {
                /* If the endpoint node exists, consider it enabled */
                remote = of_graph_get_remote_port(ep);
-               if (remote)
+               if (remote) {
+                       of_node_put(remote);
+                       of_node_put(ep);
                        return true;
+               }
        }
 
        return false;