PCI: Fix pci_register_host_bridge() device_register() error handling
authorRob Herring <robh@kernel.org>
Wed, 13 May 2020 22:38:58 +0000 (17:38 -0500)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 14 May 2020 21:36:19 +0000 (16:36 -0500)
If device_register() has an error, we should bail out of
pci_register_host_bridge() rather than continuing on.

Fixes: 37d6a0a6f470 ("PCI: Add pci_register_host_bridge() interface")
Link: https://lore.kernel.org/r/20200513223859.11295-1-robh@kernel.org
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
drivers/pci/probe.c

index 77b8a145c39b813f34f845486fe6dce9ab183b4b..e21dc71b1907634c4ad5687f6e9180c511ffa609 100644 (file)
@@ -909,9 +909,10 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge)
                goto free;
 
        err = device_register(&bridge->dev);
-       if (err)
+       if (err) {
                put_device(&bridge->dev);
-
+               goto free;
+       }
        bus->bridge = get_device(&bridge->dev);
        device_enable_async_suspend(bus->bridge);
        pci_set_bus_of_node(bus);