Skip to content

Commit 01af542

Browse files
lgs2513gregkh
authored andcommitted
usb: ulpi: fix double free in ulpi_register_interface() error path
When device_register() fails, ulpi_register() calls put_device() on ulpi->dev. The device release callback ulpi_dev_release() drops the OF node reference and frees ulpi, but the current error path in ulpi_register_interface() then calls kfree(ulpi) again, causing a double free. Let put_device() handle the cleanup through ulpi_dev_release() and avoid freeing ulpi again in ulpi_register_interface(). Fixes: 289fcff ("usb: add bus type for USB ULPI") Cc: stable <stable@kernel.org> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://patch.msgid.link/20260401025142.1398996-1-lgs201920130244@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 33cfe07 commit 01af542

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

drivers/usb/common/ulpi.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,9 @@ struct ulpi *ulpi_register_interface(struct device *dev,
331331
ulpi->ops = ops;
332332

333333
ret = ulpi_register(dev, ulpi);
334-
if (ret) {
335-
kfree(ulpi);
334+
if (ret)
336335
return ERR_PTR(ret);
337-
}
336+
338337

339338
return ulpi;
340339
}

0 commit comments

Comments
 (0)