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

From: Rafael J. Wysocki

Date: Tue May 12 2026 - 12:54:21 EST


On Tue, May 12, 2026 at 6:42 PM Andy Shevchenko
<andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
>
> 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>

Thanks!

> ...
>
> > 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).

Then I can send another patch to make that warning go away ...