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

Simon Glass sjg at chromium.org
Sun Jan 8 03:50:02 CET 2023


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>
---

(no changes since v1)

 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);
 
 error:
 	debug("%s: No match found: %d\n", __func__, ret);
-- 
2.39.0.314.g84b9a713c41-goog



More information about the U-Boot mailing list