git: 6582301f83c6 - main - PCI DEN0115: Reliably check for a memory resource during probe.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Fri, 14 Jul 2023 17:32:20 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=6582301f83c6ccaede7352fc6e6d3e7b46161713

commit 6582301f83c6ccaede7352fc6e6d3e7b46161713
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2023-07-14 17:27:40 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2023-07-14 17:27:40 +0000

    PCI DEN0115: Reliably check for a memory resource during probe.
    
    rid was stack garbage, so the bus_alloc_resource_any() call could fail
    and fall through to the SMCCC version check even if a bridge had a
    memory resource.
    
    Debugging help: jrtc27
    Reviewed by:    jrtc27
    Fixes:          c9a05c072270 Add a PCI driver that follows the Arm DEN0115 spec
    Sponsored by:   DARPA
    Differential Revision:  https://reviews.freebsd.org/D41025
---
 sys/dev/pci/pci_host_generic_den0115.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/dev/pci/pci_host_generic_den0115.c b/sys/dev/pci/pci_host_generic_den0115.c
index d620a755a1ca..cfef34824965 100644
--- a/sys/dev/pci/pci_host_generic_den0115.c
+++ b/sys/dev/pci/pci_host_generic_den0115.c
@@ -71,10 +71,11 @@ pci_host_acpi_smccc_probe(device_t dev)
 		return (ENXIO);
 
 	/*
-	 * Check we have memory resources. We may have a non-memory
+	 * Check if we have memory resources. We may have a non-memory
 	 * mapped device, e.g. using the Arm PCI Configuration Space
 	 * Access Firmware Interface (DEN0115).
 	 */
+	rid = 0;
 	res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, 0);
 	if (res != NULL) {
 		bus_release_resource(dev, SYS_RES_MEMORY, rid, res);