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@vger.kernel.org Signed-off-by: Haoxiang Li lihaoxiang@isrc.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