On 10/17/2026 12:13 PM, Jiale Yao 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.
Signed-off-by: Jiale Yao <[email protected]>
---
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;
Reviewed-by: Naman Jain <[email protected]>
Regards,
Naman