Skip to content

Commit

Permalink
driver core: platform: use put_device() if device_register fail
Browse files Browse the repository at this point in the history
if device_register() returned an error! Always use put_device()
to give up the reference initialized.

Signed-off-by: Arvind Yadav <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
ArvindYadavCs authored and gregkh committed Mar 15, 2018
1 parent ef49ec1 commit c8ae167
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/base/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c8ae167

Please sign in to comment.