[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200827135205.2.I1417edfd3526143f14fea2546787ba4bb6f32ae8@changeid>
Date: Thu, 27 Aug 2020 13:52:23 -0600
From: Raul E Rangel <rrangel@...omium.org>
To: linux-input@...r.kernel.org
Cc: dmitry.torokhov@...il.com, Shirish.S@....com,
Raul E Rangel <rrangel@...omium.org>,
Rajat Jain <rajatja@...gle.com>,
Stephen Boyd <swboyd@...omium.org>,
linux-kernel@...r.kernel.org
Subject: [PATCH 2/2] Input: i8042 - Lock i8042_mutex before flushing
Make i8042_flush lock the i8042_mutex before flushing the buffer. This
will prevent i8042_flush from clearing the buffer while a PS/2 command is
in progress. I'm not sure if this is really possible. We already
hold the lock when calling i8042_command, so this makes i8042_flush have
the same behavior.
Signed-off-by: Raul E Rangel <rrangel@...omium.org>
---
drivers/input/serio/i8042.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 8590e51bcc087..b693154641500 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -254,6 +254,8 @@ static int i8042_flush(void)
int count = 0;
int retval = 0;
+ mutex_lock(&i8042_mutex);
+
spin_lock_irqsave(&i8042_lock, flags);
while ((str = i8042_read_status()) & I8042_STR_OBF) {
@@ -270,6 +272,8 @@ static int i8042_flush(void)
spin_unlock_irqrestore(&i8042_lock, flags);
+ mutex_unlock(&i8042_mutex);
+
return retval;
}
--
2.28.0.297.g1956fa8f8d-goog
Powered by blists - more mailing lists