]> git.ipfire.org Git - thirdparty/linux.git/blobdiff - drivers/usb/core/port.c
usb: core: Unregister device on component_add() failure
[thirdparty/linux.git] / drivers / usb / core / port.c
index c2bbf97a79bec1ad7458024e9b8da6b844732b72..d5bc36ca5b1f7721f0968780659c3619808b5a6f 100644 (file)
@@ -602,11 +602,14 @@ int usb_hub_create_port_device(struct usb_hub *hub, int port1)
                return retval;
        }
 
-       find_and_link_peer(hub, port1);
-
        retval = component_add(&port_dev->dev, &connector_ops);
-       if (retval)
+       if (retval) {
                dev_warn(&port_dev->dev, "failed to add component\n");
+               device_unregister(&port_dev->dev);
+               return retval;
+       }
+
+       find_and_link_peer(hub, port1);
 
        /*
         * Enable runtime pm and hold a refernce that hub_configure()