lkml.org 
[lkml]   [2018]   [Apr]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] sparc: vio: use put_device() instead of kfree()
From
Date
On 4/25/2018 7:56 AM, 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>
> ---
> arch/sparc/kernel/vio.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/sparc/kernel/vio.c b/arch/sparc/kernel/vio.c
> index 1a0fa10..32bae68 100644
> --- a/arch/sparc/kernel/vio.c
> +++ b/arch/sparc/kernel/vio.c
> @@ -403,7 +403,7 @@ static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp,
> if (err) {
> printk(KERN_ERR "VIO: Could not register device %s, err=%d\n",
> dev_name(&vdev->dev), err);
> - kfree(vdev);
> + put_device(&vdev->dev);

Hmmm... I can see why the put_device() might be a good idea, but I think
we still need the kfree() so as to not leak the memory that was
kzalloc'd above for vdev.

sln

> return NULL;
> }
> if (vdev->dp)
>

\
 
 \ /
  Last update: 2018-04-25 17:45    [W:0.059 / U:0.696 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site