drm: atmel-hlcdc: Fix OF graph parsing
authorBoris Brezillon <boris.brezillon@free-electrons.com>
Fri, 3 Jun 2016 07:17:36 +0000 (09:17 +0200)
committerBoris Brezillon <boris.brezillon@free-electrons.com>
Tue, 21 Jun 2016 12:15:45 +0000 (14:15 +0200)
atmel_hlcdc_create_outputs() iterates over OF graph nodes and releases
the node (using of_node_put()) after each iteration, which is wrong
since for_each_endpoint_of_node() is already taking care of that.

Move the of_node_put() call in the error path.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Reviewed-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Fixes: 17a8e03e7e97 ("drm: atmel-hlcdc: rework the output code to support drm bridges")

drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c

index 39802c0539b6ba5e2a3361f1441c20da2c5de2ec..3d34fc4ca8261906dbb69c9f2ab53f760f3d4c18 100644 (file)
@@ -266,9 +266,10 @@ int atmel_hlcdc_create_outputs(struct drm_device *dev)
                if (!ret)
                        ret = atmel_hlcdc_check_endpoint(dev, &ep);
 
-               of_node_put(ep_np);
-               if (ret)
+               if (ret) {
+                       of_node_put(ep_np);
                        return ret;
+               }
        }
 
        for_each_endpoint_of_node(dev->dev->of_node, ep_np) {
@@ -276,9 +277,10 @@ int atmel_hlcdc_create_outputs(struct drm_device *dev)
                if (!ret)
                        ret = atmel_hlcdc_attach_endpoint(dev, &ep);
 
-               of_node_put(ep_np);
-               if (ret)
+               if (ret) {
+                       of_node_put(ep_np);
                        return ret;
+               }
        }
 
        return 0;