bus: vexpress-config: fix device reference leak
authorJohan Hovold <johan@kernel.org>
Wed, 16 Nov 2016 17:31:30 +0000 (17:31 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Jan 2017 19:17:22 +0000 (20:17 +0100)
commit c090959b9dd8c87703e275079aa4b4a824ba3f8e upstream.

Make sure to drop the reference to the parent device taken by
class_find_device() after populating the bus.

Fixes: 3b9334ac835b ("mfd: vexpress: Convert custom func API to regmap")
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/bus/vexpress-config.c

index 6575c0fe6a4ea3a1e3bc1bae99010eefd9d7ff94..27ea64fa4f9b4a760a5870ee2e58fecb0bf8e552 100644 (file)
@@ -171,6 +171,7 @@ static int vexpress_config_populate(struct device_node *node)
 {
        struct device_node *bridge;
        struct device *parent;
+       int ret;
 
        bridge = of_parse_phandle(node, "arm,vexpress,config-bridge", 0);
        if (!bridge)
@@ -181,7 +182,11 @@ static int vexpress_config_populate(struct device_node *node)
        if (WARN_ON(!parent))
                return -ENODEV;
 
-       return of_platform_populate(node, NULL, NULL, parent);
+       ret = of_platform_populate(node, NULL, NULL, parent);
+
+       put_device(parent);
+
+       return ret;
 }
 
 static int __init vexpress_config_init(void)