of: platform: fix OF node refcount leak
authorSudeep Holla <Sudeep.Holla@arm.com>
Thu, 18 Jan 2018 10:43:39 +0000 (10:43 +0000)
committerArnd Bergmann <arnd@arndb.de>
Tue, 23 Jan 2018 09:15:11 +0000 (10:15 +0100)
We need to call of_node_put() for device nodes obtained with
of_find_node_by_path().

Fixes: 3aa0582fdb82 ("of: platform: populate /firmware/ node from of_platform_default_populate_init()")
Reported-by: Loys Ollivier <lollivier@baylibre.com>
Cc: Frank Rowand <frowand.list@gmail.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Andy Gross <andy.gross@linaro.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
drivers/of/platform.c

index 78cfb15..faf7d87 100644 (file)
@@ -519,8 +519,10 @@ static int __init of_platform_default_populate_init(void)
                of_platform_device_create(node, NULL, NULL);
 
        node = of_find_node_by_path("/firmware");
-       if (node)
+       if (node) {
                of_platform_populate(node, NULL, NULL, NULL);
+               of_node_put(node);
+       }
 
        /* Populate everything else. */
        of_platform_default_populate(NULL, NULL, NULL);