Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH v3] PCI/ACPI: Initialize the handle in acpi_get_rc_resources()
@ 2026-11-16 12:07 lirongqing
  2026-11-16 12:11 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: lirongqing @ 2026-11-16 12:07 UTC (permalink / raw)
  To: Rafael J . Wysocki, Len Brown, Bjorn Helgaas, linux-acpi,
	linux-pci, linux-kernel
  Cc: Li RongQing

From: Li RongQing <lirongqing@baidu.com>

acpi_get_devices() returns AE_OK even when the namespace walk finishes
without a match; in that case its return_value argument is not written,
because it is only updated when a match terminates the walk early.  The
caller passes an uninitialized acpi_handle, so on the no-match path a
stale stack value is handed to acpi_fetch_acpi_dev(), which treats it as
an ACPI namespace node: acpi_get_data_full() rejects a NULL handle up
front, but the garbage value passes through and is dereferenced in
acpi_ns_validate_handle(), which may crash or yield a bogus acpi_device.

Initialize the handle to NULL.  A missing match then makes
acpi_fetch_acpi_dev() return NULL, and the existing NULL check on the
returned acpi_device turns it into -ENODEV as intended.

Fixes: 169de969c018 ("PCI/ACPI: Provide acpi_get_rc_resources() for ARM64 platform")
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
Diff with v2: remove check if handle is NULL
Diff with v1: add fix tag
 drivers/pci/pci-acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index e260089..f14f74d 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);
-- 
2.9.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-16 12:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16 12:07 [PATCH v3] PCI/ACPI: Initialize the handle in acpi_get_rc_resources() lirongqing
2026-11-16 12:11 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox