[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190311155838.255314-1-ncrews@chromium.org>
Date: Mon, 11 Mar 2019 09:58:38 -0600
From: Nick Crews <ncrews@...omium.org>
To: enric.balletbo@...labora.com, bleung@...omium.org
Cc: linux-kernel@...r.kernel.org, dlaurie@...omium.org,
groeck@...gle.com, dtor@...gle.com,
Nick Crews <ncrews@...omium.org>
Subject: [PATCH] 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.
Signed-off-by: Nick Crews <ncrews@...omium.org>
---
drivers/platform/chrome/wilco_ec/mailbox.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/chrome/wilco_ec/mailbox.c b/drivers/platform/chrome/wilco_ec/mailbox.c
index f6ff29a11f1a..d6cb96168285 100644
--- a/drivers/platform/chrome/wilco_ec/mailbox.c
+++ b/drivers/platform/chrome/wilco_ec/mailbox.c
@@ -223,12 +223,12 @@ 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);
- /* Prepare request packet */
+ mutex_lock(&ec->mailbox_lock);
+
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);
return ret;
--
Powered by blists - more mailing lists