From dd57772e36f72f8d9a53d7fa4d90c974d8ebbcff Mon Sep 17 00:00:00 2001 From: Jiale Yao Date: Sat, 17 Oct 2026 14:43:13 +0800 Subject: [PATCH] Drivers: hv: vmbus: Check ACPI companion before use 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 Fixes: 9c8434238041 ("Drivers: hv: vmbus: Convert acpi_device to more generic platform_device") Reviewed-by: Naman Jain Signed-off-by: Wei Liu --- 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;