acpi: in acpi_stype_sysctl() use same logic as in acpi_sleep_state_sysctl()

Otherwise we allow to trigger an MPASS() by a userland sysctl, e.g.
hw.acpi.power_button_state=NONE.  This does not bring fully compatibility,
where as before 97d152698f setting to 'NONE' actually meant disabling
any action on a power or sleep button.  Now sysctl will fail, but with
this change it won't at least panic.

Aymeric may come with a better fix.

Fixes:	97d152698f
This commit is contained in:
Gleb Smirnoff
2025-10-27 11:22:46 -07:00
parent 2fbb6e213a
commit 34dfccc64f
+2 -2
View File
@@ -4430,8 +4430,8 @@ acpi_stype_sysctl(SYSCTL_HANDLER_ARGS)
return (EINVAL);
printf("warning: this sysctl expects a sleep type, but an ACPI S-state has "
"been passed to it. This functionality is deprecated; see acpi(4).\n");
MPASS(sstate < ACPI_S_STATE_COUNT);
if (acpi_supported_sstates[sstate] == false)
if (sstate < ACPI_S_STATE_COUNT &&
!acpi_supported_sstates[sstate])
return (EOPNOTSUPP);
new_stype = acpi_sstate_to_stype(sstate);
}