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] [day] [month] [year] [list]
Message-ID: <2025122313-pebbly-petunia-5f2d@gregkh>
Date: Tue, 23 Dec 2025 15:27:28 +0100
From: Greg KH <gregkh@...uxfoundation.org>
To: Haoxiang Li <lihaoxiang@...c.iscas.ac.cn>
Cc: heikki.krogerus@...ux.intel.com, sean.anderson@...o.com,
	linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
	stable@...r.kernel.org
Subject: Re: [PATCH] usb: ulpi: fix a double free in ulpi_register_interface()

On Fri, Dec 19, 2025 at 11:48:59PM +0800, Haoxiang Li wrote:
> If ulpi_register() fails, put_device() is called in ulpi_register(),
> kfree() in ulpi_register_interface() will result in a double free.
> 
> Also, refactor the device registration sequence to use a unified
> put_device() cleanup path, addressing multiple error returns in
> ulpi_register().
> 
> Found by code review and compiled on ubuntu 20.04.

"compiled on" doesn't really provide any information, sorry.  Espeically
for a VERY old distro release :(

How was this tested?

> Fixes: 0a907ee9d95e ("usb: ulpi: Call of_node_put correctly")
> Cc: stable@...r.kernel.org
> Signed-off-by: Haoxiang Li <lihaoxiang@...c.iscas.ac.cn>
> ---
>  drivers/usb/common/ulpi.c | 25 ++++++++++++-------------
>  1 file changed, 12 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c
> index 4a2ee447b213..c81a0cb24067 100644
> --- a/drivers/usb/common/ulpi.c
> +++ b/drivers/usb/common/ulpi.c
> @@ -278,6 +278,7 @@ static int ulpi_register(struct device *dev, struct ulpi *ulpi)
>  	int ret;
>  	struct dentry *root;
>  
> +	device_initialize(&ulpi->dev);
>  	ulpi->dev.parent = dev; /* needed early for ops */
>  	ulpi->dev.bus = &ulpi_bus;
>  	ulpi->dev.type = &ulpi_dev_type;
> @@ -287,19 +288,15 @@ static int ulpi_register(struct device *dev, struct ulpi *ulpi)
>  
>  	ret = ulpi_of_register(ulpi);
>  	if (ret)
> -		return ret;
> +		goto err_register;
>  
>  	ret = ulpi_read_id(ulpi);
> -	if (ret) {
> -		of_node_put(ulpi->dev.of_node);
> -		return ret;
> -	}
> +	if (ret)
> +		goto err_register;
>  
> -	ret = device_register(&ulpi->dev);

Splitting this up into init/add instead of just register is usually only
done if you _HAVE_ to do that.  I really don't see why that is required
here at all, sorry.  Are you sure this is the correct solution?

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ