slimbus: core: use put_device() instead of kfree()
diff mbox

Message ID 9d7f5ca30baa3a336b145a96a631a8c093f54d8b.1520418001.git.arvind.yadav.cs@gmail.com
State New
Headers show

Commit Message

Arvind Yadav March 7, 2018, 10:22 a.m. UTC
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 <arvind.yadav.cs@gmail.com>
---
 drivers/slimbus/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Srinivas Kandagatla March 7, 2018, 10:45 a.m. UTC | #1
On 07/03/18 10:22, Arvind Yadav wrote:
> 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 <arvind.yadav.cs@gmail.com>
> ---
>   drivers/slimbus/core.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
Looks good for me,

Will queue it up.

> diff --git a/drivers/slimbus/core.c b/drivers/slimbus/core.c
> index 4988a8f..7ddfc67 100644
> --- a/drivers/slimbus/core.c
> +++ b/drivers/slimbus/core.c
> @@ -141,7 +141,7 @@ static struct slim_device *slim_alloc_device(struct slim_controller *ctrl,
>   	sbdev->e_addr = *eaddr;
>   	ret = slim_add_device(ctrl, sbdev, node);
>   	if (ret) {
> -		kfree(sbdev);
> +		put_device(&sbdev->dev);
>   		return NULL;
>   	}
>   
> 

thanks,
srini

Patch
diff mbox

diff --git a/drivers/slimbus/core.c b/drivers/slimbus/core.c
index 4988a8f..7ddfc67 100644
--- a/drivers/slimbus/core.c
+++ b/drivers/slimbus/core.c
@@ -141,7 +141,7 @@  static struct slim_device *slim_alloc_device(struct slim_controller *ctrl,
 	sbdev->e_addr = *eaddr;
 	ret = slim_add_device(ctrl, sbdev, node);
 	if (ret) {
-		kfree(sbdev);
+		put_device(&sbdev->dev);
 		return NULL;
 	}