From: Tzung-Bi Shih <tzungbi@kernel.org>
To: bleung@chromium.org, groeck@chromium.org
Cc: chrome-platform@lists.linux.dev, tzungbi@kernel.org,
robertzieba@google.com, markhas@chromium.org,
bhanumaiya@chromium.org
Subject: [PATCH] platform/chrome: cros_ec_uart: fix race condition
Date: Thu, 29 Dec 2022 17:47:38 +0800 [thread overview]
Message-ID: <20221229094738.2304044-1-tzungbi@kernel.org> (raw)
From: Robert Zieba <robertzieba@google.com>
serdev_device_set_client_ops() is called before `ec_dev` is fully
initialized. This can result in cros_ec_uart_rx_bytes() being called
while `ec_dev` is still not initialized, resulting in a kernel panic.
Call serdev_device_set_client_ops() after `ec_dev` is initialized.
Fixes: 04a8bdd135cc ("platform/chrome: cros_ec_uart: Add transport layer")
Signed-off-by: Robert Zieba <robertzieba@google.com>
[tzungbi: modified commit message and fixed context conflict.]
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
---
This is from https://crrev.com/c/3490635. I just found the patch when
reviewing some downstream patches.
drivers/platform/chrome/cros_ec_uart.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/chrome/cros_ec_uart.c b/drivers/platform/chrome/cros_ec_uart.c
index 0cef2888dffd..6916069f1599 100644
--- a/drivers/platform/chrome/cros_ec_uart.c
+++ b/drivers/platform/chrome/cros_ec_uart.c
@@ -270,7 +270,6 @@ static int cros_ec_uart_probe(struct serdev_device *serdev)
}
serdev_device_set_drvdata(serdev, ec_dev);
- serdev_device_set_client_ops(serdev, &cros_ec_uart_client_ops);
init_waitqueue_head(&ec_uart->response.wait_queue);
ec_uart->serdev = serdev;
@@ -300,6 +299,8 @@ static int cros_ec_uart_probe(struct serdev_device *serdev)
sizeof(struct ec_response_get_protocol_info);
ec_dev->dout_size = sizeof(struct ec_host_request);
+ serdev_device_set_client_ops(serdev, &cros_ec_uart_client_ops);
+
return cros_ec_register(ec_dev);
}
--
2.39.0.314.g84b9a713c41-goog
next reply other threads:[~2022-12-29 9:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-29 9:47 Tzung-Bi Shih [this message]
2022-12-29 16:57 ` [PATCH] platform/chrome: cros_ec_uart: fix race condition Mark Hasemeyer
2022-12-29 20:09 ` Guenter Roeck
2023-01-03 18:33 ` Mark Hasemeyer
2022-12-29 20:07 ` Guenter Roeck
2023-01-03 5:40 ` patchwork-bot+chrome-platform
2023-01-03 8:10 ` patchwork-bot+chrome-platform
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=20221229094738.2304044-1-tzungbi@kernel.org \
--to=tzungbi@kernel.org \
--cc=bhanumaiya@chromium.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=groeck@chromium.org \
--cc=markhas@chromium.org \
--cc=robertzieba@google.com \
/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