Skip to content

Commit

Permalink
PCI: Fix pci_register_host_bridge() device_register() error handling
Browse files Browse the repository at this point in the history
[ Upstream commit 1b54ae8 ]

If device_register() has an error, we should bail out of
pci_register_host_bridge() rather than continuing on.

Fixes: 37d6a0a ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
robherring authored and gregkh committed Jun 24, 2020
1 parent 79e45cb commit 48f5405
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/pci/probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -818,9 +818,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);
Expand Down

0 comments on commit 48f5405

Please sign in to comment.