[PATCH] ARM: locomo: use put_device() instead of kfree()

2018-04-25 Thread Arvind Yadav
Never directly free @dev after calling device_register(), even
if it returned an error. Always use put_device() to give up the
reference initialized.

Signed-off-by: Arvind Yadav 
---
 arch/arm/common/locomo.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/arm/common/locomo.c b/arch/arm/common/locomo.c
index 51936bd..23a5079 100644
--- a/arch/arm/common/locomo.c
+++ b/arch/arm/common/locomo.c
@@ -226,8 +226,7 @@ locomo_init_one_child(struct locomo *lchip, struct 
locomo_dev_info *info)
 
dev = kzalloc(sizeof(struct locomo_dev), GFP_KERNEL);
if (!dev) {
-   ret = -ENOMEM;
-   goto out;
+   return -ENOMEM;
}
 
/*
@@ -256,10 +255,9 @@ locomo_init_one_child(struct locomo *lchip, struct 
locomo_dev_info *info)
NO_IRQ : lchip->irq_base + info->irq[0];
 
ret = device_register(>dev);
-   if (ret) {
- out:
-   kfree(dev);
-   }
+   if (ret)
+   put_device(>dev);
+
return ret;
 }
 
-- 
2.7.4



[PATCH] ARM: locomo: use put_device() instead of kfree()

2018-04-25 Thread Arvind Yadav
Never directly free @dev after calling device_register(), even
if it returned an error. Always use put_device() to give up the
reference initialized.

Signed-off-by: Arvind Yadav 
---
 arch/arm/common/locomo.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/arm/common/locomo.c b/arch/arm/common/locomo.c
index 51936bd..23a5079 100644
--- a/arch/arm/common/locomo.c
+++ b/arch/arm/common/locomo.c
@@ -226,8 +226,7 @@ locomo_init_one_child(struct locomo *lchip, struct 
locomo_dev_info *info)
 
dev = kzalloc(sizeof(struct locomo_dev), GFP_KERNEL);
if (!dev) {
-   ret = -ENOMEM;
-   goto out;
+   return -ENOMEM;
}
 
/*
@@ -256,10 +255,9 @@ locomo_init_one_child(struct locomo *lchip, struct 
locomo_dev_info *info)
NO_IRQ : lchip->irq_base + info->irq[0];
 
ret = device_register(>dev);
-   if (ret) {
- out:
-   kfree(dev);
-   }
+   if (ret)
+   put_device(>dev);
+
return ret;
 }
 
-- 
2.7.4