[PATCH] Drivers: hv: vmbus: Check ACPI companion before use

From: Jiale Yao

Date: Sat Oct 17 2026 - 02:43:45 EST


Platform drivers can be forced to bind to devices outside their match
tables through driver_override. vmbus_acpi_add() assumes that every bound
device has an ACPI companion and dereferences it without checking.

Return -ENODEV when the companion is absent to avoid a NULL pointer
dereference.

Signed-off-by: Jiale Yao <yaojiale02@xxxxxxx>
---
drivers/hv/vmbus_drv.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 4692687cdbf3..28f459679406 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -2571,10 +2571,14 @@ EXPORT_SYMBOL_GPL(vmbus_free_mmio);
#ifdef CONFIG_ACPI
static int vmbus_acpi_add(struct platform_device *pdev)
{
+ struct acpi_device *ancestor;
+ struct acpi_device *device;
acpi_status result;
int ret_val = -ENODEV;
- struct acpi_device *ancestor;
- struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
+
+ device = ACPI_COMPANION(&pdev->dev);
+ if (!device)
+ return -ENODEV;

vmbus_root_device = &device->dev;

--
2.34.1