summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Crews <ncrews@chromium.org>2019-03-11 09:58:38 -0600
committerBenson Leung <bleung@chromium.org>2019-03-18 10:29:40 -0700
commit6f8f89ce1e18de1e391c9c1c14e7738881d1c00c (patch)
treee17e26e215c3fb454afa41633ab4408f04f36b2c
parent2794449576a6024e203eca5cc2c1a3ae33102b8e (diff)
platform/chrome: Fix locking pattern in wilco_ec_mailbox()
Before, ec->data_buffer could be written to from multiple contexts at the same time. Since the ec is shared data, it needs to be inside the mutex as well. Fixes: 7b3d4f44abf0 ("platform/chrome: Add new driver for Wilco EC") Signed-off-by: Nick Crews <ncrews@chromium.org> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com> Signed-off-by: Benson Leung <bleung@chromium.org>
-rw-r--r--drivers/platform/chrome/wilco_ec/mailbox.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/platform/chrome/wilco_ec/mailbox.c b/drivers/platform/chrome/wilco_ec/mailbox.c
index f6ff29a11f1a..14355668ddfa 100644
--- a/drivers/platform/chrome/wilco_ec/mailbox.c
+++ b/drivers/platform/chrome/wilco_ec/mailbox.c
@@ -223,11 +223,11 @@ int wilco_ec_mailbox(struct wilco_ec_device *ec, struct wilco_ec_message *msg)
msg->command, msg->type, msg->flags, msg->response_size,
msg->request_size);
+ mutex_lock(&ec->mailbox_lock);
/* Prepare request packet */
rq = ec->data_buffer;
wilco_ec_prepare(msg, rq);
- mutex_lock(&ec->mailbox_lock);
ret = wilco_ec_transfer(ec, msg, rq);
mutex_unlock(&ec->mailbox_lock);