diff mbox series

[QUERY] thunderbolt: Should usb4_port_device_add() return ERR_PTR() on component_add() failure?

Message ID 20250622140455.2884518-1-alok.a.tiwari@oracle.com
State New
Headers show
Series [QUERY] thunderbolt: Should usb4_port_device_add() return ERR_PTR() on component_add() failure? | expand

Commit Message

Alok Tiwari June 22, 2025, 2:04 p.m. UTC
I noticed that in usb4_port_device_add(), when component_add() fails,
the function logs an error and calls device_unregister(),
but does not return an ERR_PTR(ret) immediately:
Should this be changed to return ERR_PTR(ret); right after device_unregister()?

ret = component_add(&usb4->dev, &connector_ops);
if (ret) {
    dev_err(&usb4->dev, "failed to add component\n");
    device_unregister(&usb4->dev);
    // Missing return here?
}

Thanks,
Alok

---
diff mbox series

Patch

diff --git a/drivers/thunderbolt/usb4_port.c b/drivers/thunderbolt/usb4_port.c
index 852a45fcd19d1..6db4a0c8e4496 100644
--- a/drivers/thunderbolt/usb4_port.c
+++ b/drivers/thunderbolt/usb4_port.c
@@ -323,6 +323,7 @@  struct usb4_port *usb4_port_device_add(struct tb_port *port)
        if (ret) {
                dev_err(&usb4->dev, "failed to add component\n");
                device_unregister(&usb4->dev);
+               return ERR_PTR(ret);
        }

        if (!tb_is_upstream_port(port))