Re: [PATCH v1] platform/surface: surfacepro3_button: Check ACPI_COMPANION()

From: Andy Shevchenko

Date: Tue May 12 2026 - 12:44:31 EST


On Tue, May 12, 2026 at 06:30: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 a requisite ACPI_COMPANION() check against NULL to the
> surfacepro3_button driver.

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

...

> strscpy(acpi_device_name(device), SURFACE_BUTTON_DEVICE_NAME);
> - snprintf(button->phys, sizeof(button->phys), "%s/buttons", hid);
> + snprintf(button->phys, sizeof(button->phys), "%s/buttons",
> + acpi_device_hid(device));

I'm wondering if some CIs will now generate a snprintf() warning
(this was in the original code if the compiler can prove no truncation
of the string, though).

--
With Best Regards,
Andy Shevchenko