diff mbox series

[1/2] PCI: Fix pci_register_host_bridge() device_register() error handling

Message ID 20200513223859.11295-1-robh@kernel.org
State New
Headers show
Series [1/2] PCI: Fix pci_register_host_bridge() device_register() error handling | expand

Commit Message

Rob Herring (Arm) May 13, 2020, 10:38 p.m. UTC
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")
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Rob Herring <robh@kernel.org>
---
 drivers/pci/probe.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Lorenzo Pieralisi May 14, 2020, 4:41 p.m. UTC | #1
On Wed, May 13, 2020 at 05:38:58PM -0500, Rob Herring wrote:
> 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")
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
>  drivers/pci/probe.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Reviewed-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>

> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 77b8a145c39b..e21dc71b1907 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -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);
> -- 
> 2.20.1
>
Arnd Bergmann May 14, 2020, 9:16 p.m. UTC | #2
On Thu, May 14, 2020 at 12:39 AM Rob Herring <robh@kernel.org> wrote:
>
> 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")
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---

Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Bjorn Helgaas May 14, 2020, 9:37 p.m. UTC | #3
On Wed, May 13, 2020 at 05:38:58PM -0500, Rob Herring wrote:
> 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")
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Signed-off-by: Rob Herring <robh@kernel.org>

Both applied to pci/enumeration for v5.8, thanks!

> ---
>  drivers/pci/probe.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 77b8a145c39b..e21dc71b1907 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -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);
> -- 
> 2.20.1
>
diff mbox series

Patch

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 77b8a145c39b..e21dc71b1907 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -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);