mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tong Zhang <ztong0001@gmail.com>
To: Benson Leung <bleung@chromium.org>,
	Guenter Roeck <groeck@chromium.org>,
	linux-kernel@vger.kernel.org
Cc: Tong Zhang <ztong0001@gmail.com>
Subject: [PATCH] platform/chrome: cros_ec: honor acpi=off
Date: Tue, 15 Feb 2022 22:26:01 -0800	[thread overview]
Message-ID: <20220216062601.779690-1-ztong0001@gmail.com> (raw)

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>
---
 drivers/platform/chrome/cros_ec_lpc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c
index d6306d2a096f..95412a55ed8d 100644
--- a/drivers/platform/chrome/cros_ec_lpc.c
+++ b/drivers/platform/chrome/cros_ec_lpc.c
@@ -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))
-- 
2.25.1


             reply	other threads:[~2022-02-16  6:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-16  6:26 Tong Zhang [this message]
2022-02-16 11:24 ` kernel test robot
2022-02-16 12:35 ` kernel test robot
2022-02-16 16:12 ` Guenter Roeck
2022-02-16 16:43   ` Tong Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220216062601.779690-1-ztong0001@gmail.com \
    --to=ztong0001@gmail.com \
    --cc=bleung@chromium.org \
    --cc=groeck@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®