git: 992f5b16afa7 - main - pci_host_generic: Set a valid error if allocating a range resource fails

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Fri, 16 Feb 2024 00:05:24 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=992f5b16afa73d0ea63c8a886a78ad2eda928e37

commit 992f5b16afa73d0ea63c8a886a78ad2eda928e37
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-02-16 00:05:09 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-02-16 00:05:09 +0000

    pci_host_generic: Set a valid error if allocating a range resource fails
    
    Previously pci_host_generic_attach was returning 0 (success)
    incorrectly if allocating a range failed.  The error value was 0 from
    the previously successful call to bus_set_resource in this case.
    
    Fixes:          d79b6b8ec267 pci_host_generic: Don't rewrite resource start address for translation
---
 sys/dev/pci/pci_host_generic.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sys/dev/pci/pci_host_generic.c b/sys/dev/pci/pci_host_generic.c
index 45a478634d20..ca384d9a1483 100644
--- a/sys/dev/pci/pci_host_generic.c
+++ b/sys/dev/pci/pci_host_generic.c
@@ -216,6 +216,7 @@ pci_host_generic_core_attach(device_t dev)
 		if (sc->ranges[tuple].res == NULL) {
 			device_printf(dev,
 			    "failed to allocate resource for range %d\n", tuple);
+			error = ENXIO;
 			goto err_rman_manage;
 		}
 	}