Re:[PATCH] Drivers: hv: vmbus: Check ACPI companion before use
From: jiale yao
Date: Sat Oct 17 2026 - 03:41:17 EST
At 2026-10-17 14:43:13, "Jiale Yao" <yaojiale02@xxxxxxx> wrote:
>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.
>
Fixes: 9c8434238041 ("Drivers: hv: vmbus: Convert acpi_device to more generic platform_device")
>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