Skip to content

Commit

Permalink
platform/chrome: cros_ec: honor acpi=off
Browse files Browse the repository at this point in the history
when acpi=off is provided in bootarg, kernel crash with

 BUG: kernel NULL pointer dereference, address: 0000000000000018
 RIP: 0010:acpi_ns_walk_namespace+0x57/0x280
  <TASK>
 ? acpi_get_devices+0x140/0x140
 cros_ec_lpc_init+0x25/0x100

Driver should check if ACPI is disabled before calling acpi_get_devices(),
otherwise acpi_walk_namespace() will dereference null pointer since the
acpi_gbl_root_node is not initialized.
This is a common pattern and should be fixed in ACPI framework to prevent
such crash in the future, but since many drivers are already doing explicit
check(acpi_disable) we do the same thing here.

Signed-off-by: Tong Zhang <ztong0001@gmail.com>
  • Loading branch information
lzto authored and intel-lab-lkp committed Feb 16, 2022
1 parent ffebd90 commit 66345a4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/platform/chrome/cros_ec_lpc.c
Expand Up @@ -550,6 +550,9 @@ static int __init cros_ec_lpc_init(void)
int ret;
acpi_status status;

if (acpi_disable)
return -ENODEV;

status = acpi_get_devices(ACPI_DRV_NAME, cros_ec_lpc_parse_device,
&cros_ec_lpc_acpi_device_found, NULL);
if (ACPI_FAILURE(status))
Expand Down

0 comments on commit 66345a4

Please sign in to comment.