Re: [PATCH] cxl/acpi: Check ACPI companion before use

From: Jonathan Cameron

Date: Fri Sep 25 2026 - 18:48:04 EST


On Thu, 24 Sep 2026 09:42:47 -0700
Davidlohr Bueso <dave@xxxxxxxxxxxx> wrote:

> On Thu, 24 Sep 2026, Jiale Yao wrote:
>
> >Platform drivers can be forced to match devices outside their ID tables
> >through driver_override. cxl_acpi_probe() assumes that every bound device
> >has an ACPI companion and dereferences adev->dev.bus without checking the
> >result of ACPI_COMPANION(). Force-binding cxl_acpi to a platform device
> >without a companion therefore causes a NULL pointer dereference.
> >
> >This was reproduced by setting the driver override for the pcspkr platform
> >device to cxl_acpi and binding it through sysfs:
> >
> > BUG: kernel NULL pointer dereference, address: 0000000000000280
> > #PF: supervisor read access in kernel mode
> > RIP: cxl_acpi_probe+0xf4/0x220
> > Call Trace:
> > platform_probe+0x4d/0x80
> > really_probe+0x106/0x370
> > device_driver_attach+0x4c/0xa0
> > bind_store+0xd0/0x100
> >
> >Commit 2b3a5dabe89e ("platform/surface: acpi-notify: Check ACPI
> >companion before use") fixed the same force-binding issue in another
> >platform driver. Check the companion before setting up the CXL root and
> >return -ENODEV when it is absent.
> >
> >Fixes: 7d4b5ca2e2cb ("cxl/acpi: Add downstream port data to cxl_port instances")
> >Cc: stable@xxxxxxxxxxxxxxx
> >Signed-off-by: Jiale Yao <yaojiale02@xxxxxxx>
>
> With Dave's comment,
>
> Reviewed-by: Davidlohr Bueso <dave@xxxxxxxxxxxx>
Andy Shevchenko was looking at ways to have drivers set a flag to
disable matches on driver_override. Not sure if that is still ongoing.

+CC Andy

Jonathan