[PATCH 2/4] driver core: platform: use put_device() if device_register fail

2018-03-10 Thread Arvind Yadav
if device_register() returned an error! Always use put_device()
to give up the reference initialized.

Signed-off-by: Arvind Yadav 
---
 drivers/base/platform.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index f1bf7b3..8075ddc 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(_bus);
-   if (error)
+   if (error) {
+   put_device(_bus);
return error;
+   }
error =  bus_register(_bus_type);
if (error)
device_unregister(_bus);
-- 
2.7.4



[PATCH 2/4] driver core: platform: use put_device() if device_register fail

2018-03-10 Thread Arvind Yadav
if device_register() returned an error! Always use put_device()
to give up the reference initialized.

Signed-off-by: Arvind Yadav 
---
 drivers/base/platform.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index f1bf7b3..8075ddc 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(_bus);
-   if (error)
+   if (error) {
+   put_device(_bus);
return error;
+   }
error =  bus_register(_bus_type);
if (error)
device_unregister(_bus);
-- 
2.7.4