driver core: platform: use put_device() if device_register fail

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>
This commit is contained in:
Arvind Yadav 2018-03-11 11:25:49 +05:30 committed by Greg Kroah-Hartman
parent ef49ec1dc3
commit c8ae1674cd
1 changed files with 3 additions and 1 deletions

View 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);