]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
drm/sun4i: Fix releasing node when enumerating enpoints
authorJernej Skrabec <jernej.skrabec@siol.net>
Mon, 25 Jun 2018 12:02:46 +0000 (14:02 +0200)
committerJuerg Haefliger <juergh@canonical.com>
Wed, 24 Jul 2019 01:51:00 +0000 (19:51 -0600)
BugLink: https://bugs.launchpad.net/bugs/1836287
[ Upstream commit 367c359aa8637b15ee8df6335c5a29b7623966ec ]

sun4i_drv_add_endpoints() has a memory leak since it uses of_node_put()
when remote is equal to NULL and does nothing when remote has a valid
pointer.

Invert the logic to fix memory leak.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180625120304.7543-7-jernej.skrabec@siol.net
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/gpu/drm/sun4i/sun4i_drv.c

index 75c76cdd82bc6e15fcae27aa33fe165f420c381b..4f06e59650a1752f0bcb899b51146a3ed45c0f55 100644 (file)
@@ -272,7 +272,6 @@ static int sun4i_drv_add_endpoints(struct device *dev,
                remote = of_graph_get_remote_port_parent(ep);
                if (!remote) {
                        DRM_DEBUG_DRIVER("Error retrieving the output node\n");
-                       of_node_put(remote);
                        continue;
                }
 
@@ -286,11 +285,13 @@ static int sun4i_drv_add_endpoints(struct device *dev,
 
                        if (of_graph_parse_endpoint(ep, &endpoint)) {
                                DRM_DEBUG_DRIVER("Couldn't parse endpoint\n");
+                               of_node_put(remote);
                                continue;
                        }
 
                        if (!endpoint.id) {
                                DRM_DEBUG_DRIVER("Endpoint is our panel... skipping\n");
+                               of_node_put(remote);
                                continue;
                        }
                }