media: xilinx: vipp: Fix refcount leak in xvip_graph_dma_init
authorMiaoqian Lin <linmq006@gmail.com>
Wed, 1 Jun 2022 04:25:14 +0000 (06:25 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Oct 2022 11:17:04 +0000 (13:17 +0200)
[ Upstream commit 1c78f19c3a0ea312a8178a6bfd8934eb93e9b10a ]

of_get_child_by_name() returns a node pointer with refcount
incremented, we should use of_node_put() on it when not need anymore.
Add missing of_node_put() to avoid refcount leak.

Fixes: df3305156f98 ("[media] v4l: xilinx: Add Xilinx Video IP core")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/platform/xilinx/xilinx-vipp.c

index ebfdf334d99c093605914e9f4e67d5d183f411d8..7e0d7a47adf42e7e8e716598ce2a7744d5940a65 100644 (file)
@@ -467,7 +467,7 @@ static int xvip_graph_dma_init(struct xvip_composite_device *xdev)
 {
        struct device_node *ports;
        struct device_node *port;
-       int ret;
+       int ret = 0;
 
        ports = of_get_child_by_name(xdev->dev->of_node, "ports");
        if (ports == NULL) {
@@ -477,13 +477,14 @@ static int xvip_graph_dma_init(struct xvip_composite_device *xdev)
 
        for_each_child_of_node(ports, port) {
                ret = xvip_graph_dma_init_one(xdev, port);
-               if (ret < 0) {
+               if (ret) {
                        of_node_put(port);
-                       return ret;
+                       break;
                }
        }
 
-       return 0;
+       of_node_put(ports);
+       return ret;
 }
 
 static void xvip_graph_cleanup(struct xvip_composite_device *xdev)