Re: [PATCH v1] platform/x86: Check ACPI_COMPANION() against NULL during probe

From: Andy Shevchenko

Date: Tue May 12 2026 - 03:25:50 EST


On Mon, May 11, 2026 at 09:48:26PM +0200, Rafael J. Wysocki wrote:

> Every platform driver can be forced to match a device that doesn't match
> its list of device IDs because of device_match_driver_override(), so
> platform drivers that rely on the existence of a device's ACPI companion
> object need to verify its presence.
>
> Accordingly, add requisite ACPI_COMPANION() or ACPI_HANDLE() checks
> against NULL to multiple platform/x86 drivers that have been converted
> to platform drivers from ACPI drivers recently.

> Fixes: 578bc2a53ae2 ("platform/wmi: Convert drivers to use wmidev_invoke_procedure()")
> Fixes: f7e648027d7e ("platform/x86: asus-wireless: Convert ACPI driver to a platform one")
> Fixes: ba19eb10170b ("platform/x86: asus-laptop: Convert ACPI driver to a platform one")
> Fixes: 3a96c7915d93 ("platform/x86: toshiba_haps: Convert ACPI driver to a platform one")
> Fixes: 553b2ac59fbb ("platform/x86: toshiba_bluetooth: Convert ACPI driver to a platform one")
> Fixes: 246d6cefe525 ("platform/x86: toshiba_acpi: Convert ACPI driver to a platform one")
> Fixes: 19ebacfb442b ("platform/x86: dell/dell-rbtn: Convert ACPI driver to a platform one")
> Fixes: 80b8f68b94ab ("platform/x86: system76: Convert ACPI driver to a platform one")
> Fixes: de6837243af0 ("platform/x86: panasonic-laptop: Convert ACPI driver to a platform one")
> Fixes: 6da22b031a3c ("platform/x86: fujitsu: Convert laptop driver to a platform one")
> Fixes: d5c9212ccfaa ("platform/x86: fujitsu: Convert backlight driver to a platform one")
> Fixes: bd13b265d386 ("platform/x86: fujitsu-tablet: Convert ACPI driver to a platform one")
> Fixes: 8507277ef132 ("platform/x86: wireless-hotkey: Convert ACPI driver to a platform one")
> Fixes: 3471415c8186 ("platform/x86: topstar-laptop: Convert ACPI driver to a platform one")
> Fixes: 138db7ee58c0 ("platform/x86: sony-laptop: Convert PIC driver to a platform one")
> Fixes: 14004dd31caa ("platform/x86: sony-laptop: Convert NC driver to a platform one")
> Fixes: 2d9cb20610f7 ("platform/x86: lg-laptop: Convert ACPI driver to a platform one")
> Fixes: 8a44bd3ffdb2 ("platform/x86: intel/smartconnect: Convert ACPI driver to a platform one")
> Fixes: 163a68a31f74 ("platform/x86: intel/rst: Convert ACPI driver to a platform one")
> Fixes: 079b59fd2d79 ("platform/x86: eeepc-laptop: Convert ACPI driver to a platform one")
> Fixes: b30a462720ad ("platform/x86: acer-wireless: Convert ACPI driver to a platform one")

Looking at this I would rather see the series, but am not a maintainer here and
I'm fine with the result. As a single patch or as a series

Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>

...

> static int acpi_fujitsu_probe(struct platform_device *pdev)
> {
> - struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
> + struct acpi_device *adev;
> acpi_status status;
> int error;
>
> + adev = ACPI_COMPANION(&pdev->dev);
> + if (!adev)
> + return -ENODEV;
> +
> status = acpi_walk_resources(adev->handle, METHOD_NAME__CRS,

Don't you want ACPI_HANDLE() actually? (Note it's not directly related
to this change, but perhaps a material for further improvements.)

> fujitsu_walk_resources, NULL);

...

> + device = ACPI_COMPANION(&pdev->dev);
> + if (!device)
> + return -ENODEV;
> +
> + pdev_info.fwnode = acpi_fwnode_handle(device),
> +
> status = acpi_install_address_space_handler(device->handle, LG_ADDRESS_SPACE_ID,

Similar Q here. And some more drivers seem use handle in the given context.

> &lg_laptop_address_space_handler,
> NULL, &pdev->dev);

--
With Best Regards,
Andy Shevchenko