aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/platform.c
diff options
context:
space:
mode:
authorArvind Yadav <arvind.yadav.cs@gmail.com>2018-03-11 11:25:49 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-03-15 14:37:04 +0100
commitc8ae1674cd0d688661a8b85b8b2d940516933322 (patch)
treeb663b1e6fe1085a0eed8303920537234fec895a4 /drivers/base/platform.c
parentbase: soc: use put_device() instead of kfree() (diff)
downloadlinux-dev-c8ae1674cd0d688661a8b85b8b2d940516933322.tar.xz
linux-dev-c8ae1674cd0d688661a8b85b8b2d940516933322.zip
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>
Diffstat (limited to 'drivers/base/platform.c')
-rw-r--r--drivers/base/platform.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index f1bf7b38d91c..8075ddc70a17 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -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);