* [PATCH v1] platform/x86: Check ACPI_COMPANION() against NULL during probe
@ 2026-05-11 19:48 Rafael J. Wysocki
2026-05-12 0:16 ` Jonathan Woithe
2026-05-12 7:25 ` Andy Shevchenko
0 siblings, 2 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2026-05-11 19:48 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: Hans de Goede, LKML, Linux ACPI, Corentin Chary, Luke D. Jones,
Denis Benato, Pali Rohár, Jonathan Woithe, Robert Gerlach,
Matan Ziv-Av, Kenneth Chan, Mattia Dongili, Jeremy Soller,
Azael Avalos, Andy Shevchenko, platform-driver-x86
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
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")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/platform/x86/acer-wireless.c | 8 ++++++--
drivers/platform/x86/asus-laptop.c | 6 +++++-
drivers/platform/x86/dell/dell-rbtn.c | 6 +++++-
drivers/platform/x86/eeepc-laptop.c | 6 +++++-
drivers/platform/x86/fujitsu-laptop.c | 12 ++++++++++--
drivers/platform/x86/fujitsu-tablet.c | 6 +++++-
drivers/platform/x86/intel/rst.c | 6 +++++-
drivers/platform/x86/intel/smartconnect.c | 6 +++++-
drivers/platform/x86/lg-laptop.c | 9 +++++++--
drivers/platform/x86/panasonic-laptop.c | 6 +++++-
drivers/platform/x86/sony-laptop.c | 12 ++++++++++--
drivers/platform/x86/system76_acpi.c | 6 +++++-
drivers/platform/x86/toshiba_acpi.c | 6 +++++-
drivers/platform/x86/toshiba_bluetooth.c | 6 +++++-
drivers/platform/x86/toshiba_haps.c | 6 +++++-
drivers/platform/x86/wireless-hotkey.c | 9 +++++++--
16 files changed, 95 insertions(+), 21 deletions(-)
--- a/drivers/platform/x86/acer-wireless.c
+++ b/drivers/platform/x86/acer-wireless.c
@@ -37,9 +37,14 @@ static void acer_wireless_notify(acpi_ha
static int acer_wireless_probe(struct platform_device *pdev)
{
+ struct acpi_device *adev;
struct input_dev *idev;
int ret;
+ adev = ACPI_COMPANION(&pdev->dev);
+ if (!adev)
+ return -ENODEV;
+
idev = devm_input_allocate_device(&pdev->dev);
if (!idev)
return -ENOMEM;
@@ -57,8 +62,7 @@ static int acer_wireless_probe(struct pl
if (ret)
return ret;
- return acpi_dev_install_notify_handler(ACPI_COMPANION(&pdev->dev),
- ACPI_DEVICE_NOTIFY,
+ return acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY,
acer_wireless_notify,
&pdev->dev);
}
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -1826,10 +1826,14 @@ static bool asus_device_present;
static int asus_acpi_probe(struct platform_device *pdev)
{
- struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
+ struct acpi_device *device;
struct asus_laptop *asus;
int result;
+ device = ACPI_COMPANION(&pdev->dev);
+ if (!device)
+ return -ENODEV;
+
pr_notice("Asus Laptop Support version %s\n",
ASUS_LAPTOP_VERSION);
asus = kzalloc_obj(struct asus_laptop);
--- a/drivers/platform/x86/dell/dell-rbtn.c
+++ b/drivers/platform/x86/dell/dell-rbtn.c
@@ -396,11 +396,15 @@ static void rbtn_cleanup(struct device *
static int rbtn_probe(struct platform_device *pdev)
{
- struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
struct rbtn_data *rbtn_data;
+ struct acpi_device *device;
enum rbtn_type type;
int ret = 0;
+ device = ACPI_COMPANION(&pdev->dev);
+ if (!device)
+ return -ENODEV;
+
type = rbtn_check(device);
if (type == RBTN_UNKNOWN) {
dev_info(&pdev->dev, "Unknown device type\n");
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -1363,10 +1363,14 @@ static bool eeepc_device_present;
static int eeepc_acpi_probe(struct platform_device *pdev)
{
- struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
+ struct acpi_device *device;
struct eeepc_laptop *eeepc;
int result;
+ device = ACPI_COMPANION(&pdev->dev);
+ if (!device)
+ return -ENODEV;
+
pr_notice(EEEPC_LAPTOP_NAME "\n");
eeepc = kzalloc_obj(struct eeepc_laptop);
if (!eeepc)
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -530,10 +530,14 @@ static void acpi_fujitsu_bl_notify(acpi_
static int acpi_fujitsu_bl_probe(struct platform_device *pdev)
{
- struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
+ struct acpi_device *device;
struct fujitsu_bl *priv;
int ret;
+ device = ACPI_COMPANION(&pdev->dev);
+ if (!device)
+ return -ENODEV;
+
if (acpi_video_get_backlight_type() != acpi_backlight_vendor)
return -ENODEV;
@@ -993,10 +997,14 @@ static void acpi_fujitsu_laptop_notify(a
static int acpi_fujitsu_laptop_probe(struct platform_device *pdev)
{
- struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
struct fujitsu_laptop *priv;
+ struct acpi_device *device;
int ret, i = 0;
+ device = ACPI_COMPANION(&pdev->dev);
+ if (!device)
+ return -ENODEV;
+
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
--- a/drivers/platform/x86/fujitsu-tablet.c
+++ b/drivers/platform/x86/fujitsu-tablet.c
@@ -445,10 +445,14 @@ static acpi_status fujitsu_walk_resource
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,
fujitsu_walk_resources, NULL);
if (ACPI_FAILURE(status) || !fujitsu.irq || !fujitsu.io_base)
--- a/drivers/platform/x86/intel/rst.c
+++ b/drivers/platform/x86/intel/rst.c
@@ -102,9 +102,13 @@ static struct device_attribute irst_time
static int irst_probe(struct platform_device *pdev)
{
- struct acpi_device *acpi = ACPI_COMPANION(&pdev->dev);
+ struct acpi_device *acpi;
int error;
+ acpi = ACPI_COMPANION(&pdev->dev);
+ if (!acpi)
+ return -ENODEV;
+
error = device_create_file(&acpi->dev, &irst_timeout_attr);
if (unlikely(error))
return error;
--- a/drivers/platform/x86/intel/smartconnect.c
+++ b/drivers/platform/x86/intel/smartconnect.c
@@ -12,10 +12,14 @@ MODULE_LICENSE("GPL");
static int smartconnect_acpi_probe(struct platform_device *pdev)
{
- acpi_handle handle = ACPI_HANDLE(&pdev->dev);
unsigned long long value;
+ acpi_handle handle;
acpi_status status;
+ handle = ACPI_HANDLE(&pdev->dev);
+ if (!handle)
+ return -ENODEV;
+
status = acpi_evaluate_integer(handle, "GAOS", NULL, &value);
if (ACPI_FAILURE(status))
return -EINVAL;
--- a/drivers/platform/x86/lg-laptop.c
+++ b/drivers/platform/x86/lg-laptop.c
@@ -761,12 +761,11 @@ static void lg_laptop_remove_address_spa
static int acpi_probe(struct platform_device *pdev)
{
- struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
struct platform_device_info pdev_info = {
- .fwnode = acpi_fwnode_handle(device),
.name = PLATFORM_NAME,
.id = PLATFORM_DEVID_NONE,
};
+ struct acpi_device *device;
acpi_status status;
int ret;
const char *product;
@@ -775,6 +774,12 @@ static int acpi_probe(struct platform_de
if (pf_device)
return 0;
+ 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,
&lg_laptop_address_space_handler,
NULL, &pdev->dev);
--- a/drivers/platform/x86/panasonic-laptop.c
+++ b/drivers/platform/x86/panasonic-laptop.c
@@ -981,11 +981,15 @@ static int acpi_pcc_hotkey_resume(struct
static int acpi_pcc_hotkey_probe(struct platform_device *pdev)
{
- struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
struct backlight_properties props;
+ struct acpi_device *device;
struct pcc_acpi *pcc;
int num_sifr, result;
+ device = ACPI_COMPANION(&pdev->dev);
+ if (!device)
+ return -ENODEV;
+
num_sifr = acpi_pcc_get_sqty(device);
/*
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -3147,11 +3147,15 @@ static void sony_nc_backlight_cleanup(vo
static int sony_nc_probe(struct platform_device *pdev)
{
- struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
+ struct acpi_device *device;
acpi_status status;
int result = 0;
struct sony_nc_value *item;
+ device = ACPI_COMPANION(&pdev->dev);
+ if (!device)
+ return -ENODEV;
+
sony_nc_acpi_device = device;
strscpy(acpi_device_class(device), "sony/hotkey");
@@ -4509,11 +4513,15 @@ static void sony_pic_remove(struct platf
static int sony_pic_probe(struct platform_device *pdev)
{
- struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
struct sony_pic_ioport *io, *tmp_io;
struct sony_pic_irq *irq, *tmp_irq;
+ struct acpi_device *device;
int result;
+ device = ACPI_COMPANION(&pdev->dev);
+ if (!device)
+ return -ENODEV;
+
spic_dev.acpi_dev = device;
strscpy(acpi_device_class(device), "sony/hotkey");
sony_pic_detect_device_type(&spic_dev);
--- a/drivers/platform/x86/system76_acpi.c
+++ b/drivers/platform/x86/system76_acpi.c
@@ -674,10 +674,14 @@ static void system76_notify(acpi_handle
// Probe a System76 platform device
static int system76_probe(struct platform_device *pdev)
{
- struct acpi_device *acpi_dev = ACPI_COMPANION(&pdev->dev);
+ struct acpi_device *acpi_dev;
struct system76_data *data;
int err;
+ acpi_dev = ACPI_COMPANION(&pdev->dev);
+ if (!acpi_dev)
+ return -ENODEV;
+
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -3374,7 +3374,7 @@ static const struct dmi_system_id toshib
static int toshiba_acpi_probe(struct platform_device *pdev)
{
- struct acpi_device *acpi_dev = ACPI_COMPANION(&pdev->dev);
+ struct acpi_device *acpi_dev;
struct toshiba_acpi_dev *dev;
const char *hci_method;
u32 dummy;
@@ -3383,6 +3383,10 @@ static int toshiba_acpi_probe(struct pla
if (toshiba_acpi)
return -EBUSY;
+ acpi_dev = ACPI_COMPANION(&pdev->dev);
+ if (!acpi_dev)
+ return -ENODEV;
+
pr_info("Toshiba Laptop ACPI Extras version %s\n",
TOSHIBA_ACPI_VERSION);
--- a/drivers/platform/x86/toshiba_bluetooth.c
+++ b/drivers/platform/x86/toshiba_bluetooth.c
@@ -230,10 +230,14 @@ static int toshiba_bt_resume(struct devi
static int toshiba_bt_rfkill_probe(struct platform_device *pdev)
{
- struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
struct toshiba_bluetooth_dev *bt_dev;
+ struct acpi_device *device;
int result;
+ device = ACPI_COMPANION(&pdev->dev);
+ if (!device)
+ return -ENODEV;
+
result = toshiba_bluetooth_present(device->handle);
if (result)
return result;
--- a/drivers/platform/x86/toshiba_haps.c
+++ b/drivers/platform/x86/toshiba_haps.c
@@ -182,13 +182,17 @@ static int toshiba_haps_available(acpi_h
static int toshiba_haps_probe(struct platform_device *pdev)
{
- struct acpi_device *acpi_dev = ACPI_COMPANION(&pdev->dev);
struct toshiba_haps_dev *haps;
+ struct acpi_device *acpi_dev;
int ret;
if (toshiba_haps)
return -EBUSY;
+ acpi_dev = ACPI_COMPANION(&pdev->dev);
+ if (!acpi_dev)
+ return -ENODEV;
+
if (!toshiba_haps_available(acpi_dev->handle))
return -ENODEV;
--- a/drivers/platform/x86/wireless-hotkey.c
+++ b/drivers/platform/x86/wireless-hotkey.c
@@ -89,9 +89,14 @@ static void wl_notify(acpi_handle handle
static int wl_probe(struct platform_device *pdev)
{
+ struct acpi_device *adev;
struct wl_button *button;
int err;
+ adev = ACPI_COMPANION(&pdev->dev);
+ if (!adev)
+ return -ENODEV;
+
button = kzalloc_obj(struct wl_button);
if (!button)
return -ENOMEM;
@@ -104,8 +109,8 @@ static int wl_probe(struct platform_devi
kfree(button);
return err;
}
- err = acpi_dev_install_notify_handler(ACPI_COMPANION(&pdev->dev),
- ACPI_DEVICE_NOTIFY, wl_notify, button);
+ err = acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY,
+ wl_notify, button);
if (err) {
pr_err("Failed to install ACPI notify handler\n");
wireless_input_destroy(&pdev->dev);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1] platform/x86: Check ACPI_COMPANION() against NULL during probe
2026-05-11 19:48 [PATCH v1] platform/x86: Check ACPI_COMPANION() against NULL during probe Rafael J. Wysocki
@ 2026-05-12 0:16 ` Jonathan Woithe
2026-05-12 7:25 ` Andy Shevchenko
1 sibling, 0 replies; 6+ messages in thread
From: Jonathan Woithe @ 2026-05-12 0:16 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Ilpo Järvinen, Hans de Goede, LKML, Linux ACPI,
Corentin Chary, Luke D. Jones, Denis Benato, Pali Rohár,
Robert Gerlach, Matan Ziv-Av, Kenneth Chan, Mattia Dongili,
Jeremy Soller, Azael Avalos, Andy Shevchenko, platform-driver-x86
On Mon, May 11, 2026 at 09:48:26PM +0200, Rafael J. Wysocki wrote:
> From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
>
> 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.
For the fujitsu-laptop portions of the patch as below:
Acked-by: Jonathan Woithe <jwoithe@just42.net>
Regards
jonathan
--
> :
> Fixes: 6da22b031a3c ("platform/x86: fujitsu: Convert laptop driver to a platform one")
> Fixes: d5c9212ccfaa ("platform/x86: fujitsu: Convert backlight driver to a platform one")
> :
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> drivers/platform/x86/fujitsu-laptop.c | 12 ++++++++++--
> :
> --- a/drivers/platform/x86/fujitsu-laptop.c
> +++ b/drivers/platform/x86/fujitsu-laptop.c
> @@ -530,10 +530,14 @@ static void acpi_fujitsu_bl_notify(acpi_
>
> static int acpi_fujitsu_bl_probe(struct platform_device *pdev)
> {
> - struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
> + struct acpi_device *device;
> struct fujitsu_bl *priv;
> int ret;
>
> + device = ACPI_COMPANION(&pdev->dev);
> + if (!device)
> + return -ENODEV;
> +
> if (acpi_video_get_backlight_type() != acpi_backlight_vendor)
> return -ENODEV;
>
> @@ -993,10 +997,14 @@ static void acpi_fujitsu_laptop_notify(a
>
> static int acpi_fujitsu_laptop_probe(struct platform_device *pdev)
> {
> - struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
> struct fujitsu_laptop *priv;
> + struct acpi_device *device;
> int ret, i = 0;
>
> + device = ACPI_COMPANION(&pdev->dev);
> + if (!device)
> + return -ENODEV;
> +
> priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
> if (!priv)
> return -ENOMEM;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1] platform/x86: Check ACPI_COMPANION() against NULL during probe
2026-05-11 19:48 [PATCH v1] platform/x86: Check ACPI_COMPANION() against NULL during probe Rafael J. Wysocki
2026-05-12 0:16 ` Jonathan Woithe
@ 2026-05-12 7:25 ` Andy Shevchenko
2026-05-12 9:50 ` Rafael J. Wysocki
2026-05-12 9:53 ` Ilpo Järvinen
1 sibling, 2 replies; 6+ messages in thread
From: Andy Shevchenko @ 2026-05-12 7:25 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Ilpo Järvinen, Hans de Goede, LKML, Linux ACPI,
Corentin Chary, Luke D. Jones, Denis Benato, Pali Rohár,
Jonathan Woithe, Robert Gerlach, Matan Ziv-Av, Kenneth Chan,
Mattia Dongili, Jeremy Soller, Azael Avalos, platform-driver-x86
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@linux.intel.com>
...
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1] platform/x86: Check ACPI_COMPANION() against NULL during probe
2026-05-12 7:25 ` Andy Shevchenko
@ 2026-05-12 9:50 ` Rafael J. Wysocki
2026-05-12 9:53 ` Ilpo Järvinen
1 sibling, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2026-05-12 9:50 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Rafael J. Wysocki, Ilpo Järvinen, Hans de Goede, LKML,
Linux ACPI, Corentin Chary, Luke D. Jones, Denis Benato,
Pali Rohár, Jonathan Woithe, Robert Gerlach, Matan Ziv-Av,
Kenneth Chan, Mattia Dongili, Jeremy Soller, Azael Avalos,
platform-driver-x86
On Tue, May 12, 2026 at 9:25 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> 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@linux.intel.com>
>
> ...
>
> > 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.)
From the code flow perspective it doesn't really matter at all because
ACPI_COMPANION(dev) needs to be dereferenced anyway to get
ACPI_HANDLE(dev) sooner or later and when that happens isn't really
that important. And since acpi_handle really is a (void *) in
disguise, I slightly prefer using (struct acpi_device *) for a local
var unless the handle is used more than once in the given piece of
code.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1] platform/x86: Check ACPI_COMPANION() against NULL during probe
2026-05-12 7:25 ` Andy Shevchenko
2026-05-12 9:50 ` Rafael J. Wysocki
@ 2026-05-12 9:53 ` Ilpo Järvinen
2026-05-12 10:31 ` Rafael J. Wysocki
1 sibling, 1 reply; 6+ messages in thread
From: Ilpo Järvinen @ 2026-05-12 9:53 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Rafael J. Wysocki, Hans de Goede, LKML, Linux ACPI,
Corentin Chary, Luke D. Jones, Denis Benato, Pali Rohár,
Jonathan Woithe, Robert Gerlach, Matan Ziv-Av, Kenneth Chan,
Mattia Dongili, Jeremy Soller, Azael Avalos, platform-driver-x86
On Tue, 12 May 2026, Andy Shevchenko wrote:
> 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.
I was already wondering about when the NULL check is necessary not that
long ago, as some many places seemed to be lacking the check.
> > 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.
It would probably be better to split this per driver. Lets say somewhere
in future stable people want to backport some other fix which has this
change as a prerequisite, it will be simpler for them to handle if they're
not all together.
> As a single patch or as a series
>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> ...
>
> > 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);
>
>
--
i.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1] platform/x86: Check ACPI_COMPANION() against NULL during probe
2026-05-12 9:53 ` Ilpo Järvinen
@ 2026-05-12 10:31 ` Rafael J. Wysocki
0 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2026-05-12 10:31 UTC (permalink / raw)
To: Ilpo Järvinen, Andy Shevchenko
Cc: Rafael J. Wysocki, Hans de Goede, LKML, Linux ACPI,
Corentin Chary, Luke D. Jones, Denis Benato, Pali Rohár,
Jonathan Woithe, Robert Gerlach, Matan Ziv-Av, Kenneth Chan,
Mattia Dongili, Jeremy Soller, Azael Avalos, platform-driver-x86
On Tue, May 12, 2026 at 11:53 AM Ilpo Järvinen
<ilpo.jarvinen@linux.intel.com> wrote:
>
> On Tue, 12 May 2026, Andy Shevchenko wrote:
>
> > 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.
>
> I was already wondering about when the NULL check is necessary not that
> long ago, as some many places seemed to be lacking the check.
I have to admit that I overlooked the device_match_driver_override()
thing that is key here.
> > > 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.
>
> It would probably be better to split this per driver. Lets say somewhere
> in future stable people want to backport some other fix which has this
> change as a prerequisite, it will be simpler for them to handle if they're
> not all together.
Sure.
> > As a single patch or as a series
> >
> > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Thanks Andy!
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-05-12 10:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-11 19:48 [PATCH v1] platform/x86: Check ACPI_COMPANION() against NULL during probe Rafael J. Wysocki
2026-05-12 0:16 ` Jonathan Woithe
2026-05-12 7:25 ` Andy Shevchenko
2026-05-12 9:50 ` Rafael J. Wysocki
2026-05-12 9:53 ` Ilpo Järvinen
2026-05-12 10:31 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox