Re: [PATCH v2] PCI/ACPI: Check the found handle in acpi_get_rc_resources()

From: Rafael J. Wysocki (Intel)

Date: Sun Nov 15 2026 - 12:07:05 EST


On Sun, Nov 15, 2026 at 10:12 AM lirongqing <lirongqing@xxxxxxxxx> wrote:
>
> From: Li RongQing <lirongqing@xxxxxxxxx>
>
> acpi_get_devices() returns AE_OK even when the namespace walk finishes
> without a match, in which case the return_value argument is not written.
> The caller passes an uninitialized acpi_handle and hands it to
> acpi_fetch_acpi_dev(), which dereferences it as an ACPI node.
>
> Initialize the handle and reject a missing match.
>
> Fixes: 169de969c018 ("PCI/ACPI: Provide acpi_get_rc_resources() for ARM64 platform")
> Signed-off-by: Li RongQing <lirongqing@xxxxxxxxx>
> ---
> Diff with v1: add fixes tag
>
> drivers/pci/pci-acpi.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
> index e260089..e90e749 100644
> --- a/drivers/pci/pci-acpi.c
> +++ b/drivers/pci/pci-acpi.c
> @@ -82,7 +82,7 @@ int acpi_get_rc_resources(struct device *dev, const char *hid, u16 segment,
> {
> struct acpi_device *adev;
> acpi_status status;
> - acpi_handle handle;
> + acpi_handle handle = NULL;
> int ret;
>
> status = acpi_get_devices(hid, acpi_match_rc, &segment, &handle);
> @@ -92,6 +92,9 @@ int acpi_get_rc_resources(struct device *dev, const char *hid, u16 segment,
> return -ENODEV;
> }
>
> + if (!handle)
> + return -ENODEV;

acpi_fetch_acpi_dev() will return NULL if handle is NULL, won't it?

> +
> adev = acpi_fetch_acpi_dev(handle);
> if (!adev)
> return -ENODEV;
> --