[PATCH 26/71] dm: usb: Mark the device name as alloced when binding

Simon Glass sjg at chromium.org
Wed Dec 7 09:50:52 CET 2022

Since usb_find_and_bind_driver() allocates the device name it should tell
driver about that, to avoid memory leaks. Fix this.

Signed-off-by: Simon Glass <sjg at chromium.org>

 drivers/usb/host/usb-uclass.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
index 956e2a4e8e4..04256eff879 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -559,6 +559,8 @@ static int usb_find_and_bind_driver(struct udevice *parent,
 	if (!str)
 		return -ENOMEM;
 	ret = device_bind_driver(parent, "usb_dev_generic_drv", str, devp);
+	if (!ret)
+		device_set_name_alloced(*devp);
 	debug("%s: No match found: %d\n", __func__, ret);

More information about the U-Boot-Custodians mailing list