Linux-HyperV List
 help / color / mirror / Atom feed
* [PATCH] Drivers: hv: vmbus: Check ACPI companion before use
@ 2026-10-17  6:43 Jiale Yao
  2026-10-17  7:40 ` jiale yao
  2026-10-19  9:24 ` [PATCH] " Naman Jain
  0 siblings, 2 replies; 3+ messages in thread
From: Jiale Yao @ 2026-10-17  6:43 UTC (permalink / raw)
  To: Haiyang Zhang, Wei Liu, Dexuan Cui, linux-hyperv, linux-kernel; +Cc: Jiale Yao

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@163.com>
---
 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


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

* Re:[PATCH] Drivers: hv: vmbus: Check ACPI companion before use
  2026-10-17  6:43 [PATCH] Drivers: hv: vmbus: Check ACPI companion before use Jiale Yao
@ 2026-10-17  7:40 ` jiale yao
  2026-10-19  9:24 ` [PATCH] " Naman Jain
  1 sibling, 0 replies; 3+ messages in thread
From: jiale yao @ 2026-10-17  7:40 UTC (permalink / raw)
  To: Haiyang Zhang, Wei Liu, Dexuan Cui, linux-hyperv, linux-kernel

At 2026-10-17 14:43:13, "Jiale Yao" <yaojiale02@163.com> 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@163.com>
>---
> 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

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

* Re: [PATCH] Drivers: hv: vmbus: Check ACPI companion before use
  2026-10-17  6:43 [PATCH] Drivers: hv: vmbus: Check ACPI companion before use Jiale Yao
  2026-10-17  7:40 ` jiale yao
@ 2026-10-19  9:24 ` Naman Jain
  1 sibling, 0 replies; 3+ messages in thread
From: Naman Jain @ 2026-10-19  9:24 UTC (permalink / raw)
  To: Jiale Yao, Haiyang Zhang, Wei Liu, Dexuan Cui, linux-hyperv,
	linux-kernel



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 <yaojiale02@163.com>
> ---
>   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 <namjain@linux.microsoft.com>

Regards,
Naman

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

end of thread, other threads:[~2026-10-19  9:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-17  6:43 [PATCH] Drivers: hv: vmbus: Check ACPI companion before use Jiale Yao
2026-10-17  7:40 ` jiale yao
2026-10-19  9:24 ` [PATCH] " Naman Jain

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