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: <004f59c4-7401-473f-b15f-02aa5151374b@wanadoo.fr>
Date: Wed, 4 Sep 2024 19:41:32 +0200
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: zhangjiao2 <zhangjiao2@...s.chinamobile.com>
Cc: openipmi-developer@...ts.sourceforge.net, linux-kernel@...r.kernel.org,
 minyard@....org
Subject: Re: [PATCH] ipmi: Use devm_kasprintf

Le 04/09/2024 à 06:12, zhangjiao2 a écrit :
> From: zhang jiao <zhangjiao2@...s.chinamobile.com>
> 
> Use devm_kasprintf to simplify code.

Hi,

I don't think that it is correct because __ipmi_bmc_register() is not a 
probe function ans is not called from a probe function. So it is really 
unlikely that a devm_ function is correct.

The kasprintf() you are removing is balanced by a kfree() in 
__ipmi_bmc_unregister().
So you patch would lead to a potential double-free issue.

CJ

> 
> Signed-off-by: zhang jiao <zhangjiao2@...s.chinamobile.com>
> ---
>   drivers/char/ipmi/ipmi_msghandler.c | 9 ++-------
>   1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
> index e12b531f5c2f..5d78b1fe49a8 100644
> --- a/drivers/char/ipmi/ipmi_msghandler.c
> +++ b/drivers/char/ipmi/ipmi_msghandler.c
> @@ -3213,7 +3213,7 @@ static int __ipmi_bmc_register(struct ipmi_smi *intf,
>   
>   	if (intf_num == -1)
>   		intf_num = intf->intf_num;
> -	intf->my_dev_name = kasprintf(GFP_KERNEL, "ipmi%d", intf_num);
> +	intf->my_dev_name = devm_kasprintf(intf->si_dev, GFP_KERNEL, "ipmi%d", intf_num);
>   	if (!intf->my_dev_name) {
>   		rv = -ENOMEM;
>   		dev_err(intf->si_dev, "Unable to allocate link from BMC: %d\n",
> @@ -3226,7 +3226,7 @@ static int __ipmi_bmc_register(struct ipmi_smi *intf,
>   	if (rv) {
>   		dev_err(intf->si_dev, "Unable to create symlink to bmc: %d\n",
>   			rv);
> -		goto out_free_my_dev_name;
> +		goto out_unlink1;
>   	}
>   
>   	intf->bmc_registered = true;
> @@ -3237,11 +3237,6 @@ static int __ipmi_bmc_register(struct ipmi_smi *intf,
>   	intf->in_bmc_register = false;
>   	return rv;
>   
> -
> -out_free_my_dev_name:
> -	kfree(intf->my_dev_name);
> -	intf->my_dev_name = NULL;
> -
>   out_unlink1:
>   	sysfs_remove_link(&intf->si_dev->kobj, "bmc");
>   


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ