]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
driver core: platform: use put_device() if device_register fail
authorArvind Yadav <arvind.yadav.cs@gmail.com>
Sun, 11 Mar 2018 05:55:49 +0000 (11:25 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 15 Mar 2018 13:37:04 +0000 (14:37 +0100)
if device_register() returned an error! Always use put_device()
to give up the reference initialized.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/platform.c

index f1bf7b38d91ca7ac69a5477ed08103f59e151bbe..8075ddc70a17825f4aa39cc52e3ef82d48f31263 100644 (file)
@@ -1153,8 +1153,10 @@ int __init platform_bus_init(void)
        early_platform_cleanup();
 
        error = device_register(&platform_bus);
-       if (error)
+       if (error) {
+               put_device(&platform_bus);
                return error;
+       }
        error =  bus_register(&platform_bus_type);
        if (error)
                device_unregister(&platform_bus);