diff options
author | Robert Zieba <robertzieba@google.com> | 2022-12-29 10:47:38 +0100 |
---|---|---|
committer | Tzung-Bi Shih <tzungbi@kernel.org> | 2023-01-05 16:27:14 +0100 |
commit | 01f95d42b8f4e88f20d68791b0a85dbb9e3d1ac9 (patch) | |
tree | e1b52572575a72eb78fe651099d2f5d2962e993a /drivers/platform/chrome | |
parent | platform/chrome: cros_ec_uart: Add DT enumeration support (diff) | |
download | linux-01f95d42b8f4e88f20d68791b0a85dbb9e3d1ac9.tar.xz linux-01f95d42b8f4e88f20d68791b0a85dbb9e3d1ac9.zip |
platform/chrome: cros_ec_uart: fix race condition
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>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Link: https://lore.kernel.org/r/20221229094738.2304044-1-tzungbi@kernel.org
Diffstat (limited to 'drivers/platform/chrome')
-rw-r--r-- | drivers/platform/chrome/cros_ec_uart.c | 3 |
1 files changed, 2 insertions, 1 deletions
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); } |