lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <5AD001C5.2040406@samsung.com>
Date:   Fri, 13 Apr 2018 10:03:01 +0900
From:   Chanwoo Choi <cw00.choi@...sung.com>
To:     Arvind Yadav <arvind.yadav.cs@...il.com>, myungjoo.ham@...sung.com,
        kyungmin.park@...sung.com
Cc:     linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org
Subject: Re: [PATCH] PM / devfreq: use put_device() instead of kfree()

Hi,

I'm sorry for the late reply.

On 2018년 03월 30일 20:44, Arvind Yadav wrote:
> Never directly free @dev after calling device_register() or
> device_unregister(), even if device_register() returned an error.
> Always use put_device() to give up the reference initialized.
> 
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@...il.com>
> ---
>  drivers/devfreq/devfreq.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index fe2af6a..a225b94 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -625,7 +625,8 @@ struct devfreq *devfreq_add_device(struct device *dev,
>  	err = device_register(&devfreq->dev);
>  	if (err) {
>  		mutex_unlock(&devfreq->lock);
> -		goto err_dev;
> +		put_device(&devfreq->dev);
> +		goto err_out;

why do you change the goto postion?
err_out is correct to free the memory of devfreq instance.

>  	}
>  
>  	devfreq->trans_table =	devm_kzalloc(&devfreq->dev,
> @@ -671,6 +672,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
>  	mutex_unlock(&devfreq_list_lock);
>  
>  	device_unregister(&devfreq->dev);
> +	devfreq = NULL;

It is wrong. If you initialize the devfreq as NULL,
never free the 'devfreq' instance.

>  err_dev:
>  	if (devfreq)
>  		kfree(devfreq);
> 


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ