Re: [PATCH v1] platform/x86: Add ACPI_COMPANION() checks against NULL to probe

From: Ilpo Järvinen

Date: Tue May 12 2026 - 05:57:56 EST


On Mon, 11 May 2026, Rafael J. Wysocki wrote:

> From: "Rafael J. Wysocki" <rafael.j.wysocki@xxxxxxxxx>
>
> 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 where they are missing.
>
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>

Don't these fixes need fixes tags?

So this part has the changes that are needed pre-7.1?
And the other is for changes going into 7.1?

> ---
> drivers/platform/x86/adv_swbutton.c | 6 +++++-
> drivers/platform/x86/hp/hp_accel.c | 3 +++
> drivers/platform/x86/intel/hid.c | 6 +++++-
> drivers/platform/x86/intel/int1092/intel_sar.c | 7 ++++++-
> drivers/platform/x86/intel/vbtn.c | 6 +++++-
> 5 files changed, 24 insertions(+), 4 deletions(-)
>
> --- a/drivers/platform/x86/adv_swbutton.c
> +++ b/drivers/platform/x86/adv_swbutton.c
> @@ -48,10 +48,14 @@ static int adv_swbutton_probe(struct pla
> {
> struct adv_swbutton *button;
> struct input_dev *input;
> - acpi_handle handle = ACPI_HANDLE(&device->dev);
> + acpi_handle handle;
> acpi_status status;
> int error;
>
> + handle = ACPI_HANDLE(&device->dev);
> + if (!handle)
> + return -ENODEV;
> +
> button = devm_kzalloc(&device->dev, sizeof(*button), GFP_KERNEL);
> if (!button)
> return -ENOMEM;
> --- a/drivers/platform/x86/hp/hp_accel.c
> +++ b/drivers/platform/x86/hp/hp_accel.c
> @@ -300,6 +300,9 @@ static int lis3lv02d_probe(struct platfo
> int ret;
>
> lis3_dev.bus_priv = ACPI_COMPANION(&device->dev);
> + if (!lis3_dev.bus_priv)
> + return -ENODEV;
> +
> lis3_dev.init = lis3lv02d_acpi_init;
> lis3_dev.read = lis3lv02d_acpi_read;
> lis3_dev.write = lis3lv02d_acpi_write;
> --- a/drivers/platform/x86/intel/hid.c
> +++ b/drivers/platform/x86/intel/hid.c
> @@ -688,12 +688,16 @@ static bool button_array_present(struct
>
> static int intel_hid_probe(struct platform_device *device)
> {
> - acpi_handle handle = ACPI_HANDLE(&device->dev);
> unsigned long long mode, dummy;
> struct intel_hid_priv *priv;
> + acpi_handle handle;
> acpi_status status;
> int err;
>
> + handle = ACPI_HANDLE(&device->dev);
> + if (!handle)
> + return -ENODEV;
> +
> intel_hid_init_dsm(handle);
>
> if (!intel_hid_evaluate_method(handle, INTEL_HID_DSM_HDMM_FN, &mode)) {
> --- a/drivers/platform/x86/intel/int1092/intel_sar.c
> +++ b/drivers/platform/x86/intel/int1092/intel_sar.c
> @@ -245,15 +245,20 @@ static void sar_get_data(int reg, struct
> static int sar_probe(struct platform_device *device)
> {
> struct wwan_sar_context *context;
> + acpi_handle handle;
> int reg;
> int result;
>
> + handle = ACPI_HANDLE(&device->dev);
> + if (!handle)
> + return -ENODEV;
> +
> context = kzalloc_obj(*context);
> if (!context)
> return -ENOMEM;
>
> context->sar_device = device;
> - context->handle = ACPI_HANDLE(&device->dev);
> + context->handle = handle;
> dev_set_drvdata(&device->dev, context);
>
> result = guid_parse(SAR_DSM_UUID, &context->guid);
> --- a/drivers/platform/x86/intel/vbtn.c
> +++ b/drivers/platform/x86/intel/vbtn.c
> @@ -275,12 +275,16 @@ static bool intel_vbtn_has_switches(acpi
>
> static int intel_vbtn_probe(struct platform_device *device)
> {
> - acpi_handle handle = ACPI_HANDLE(&device->dev);
> bool dual_accel, has_buttons, has_switches;
> struct intel_vbtn_priv *priv;
> + acpi_handle handle;
> acpi_status status;
> int err;
>
> + handle = ACPI_HANDLE(&device->dev);
> + if (!handle)
> + return -ENODEV;
> +
> dual_accel = dual_accel_detect();
> has_buttons = acpi_has_method(handle, "VBDL");
> has_switches = intel_vbtn_has_switches(handle, dual_accel);
>
>
>

--
i.