diff options
author | Furquan Shaikh <furquan@google.com> | 2018-07-23 18:31:27 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2018-07-25 23:51:08 +0000 |
commit | 6d4235d89af8eac335a6349fef2c043a57b86f21 (patch) | |
tree | 1034ddfe2c4ab9a2934a68c7b6b06dbbdf9e50a5 | |
parent | d3ec36664b4a1cfc116ba4d838ba815bfc13fc73 (diff) | |
download | chrome-ec-6d4235d89af8eac335a6349fef2c043a57b86f21.tar.gz |
keyboard_8042: Clear buffer before adding command byte
When the host attempts to read CTR, first clear the keyboard buffer to
ensure that we do not have any stale data in it. If the buffered data is
not cleared, host could end up interpreting the keypress data as CTR
thus resulting in unwanted side-effects.
Reason for putting in this change is because Linux kernel does not
disable keyboard scanning when doing a reboot or poweroff. Now, if user
keeps pressing keys while the system is booting up, kernel could end up
reading key press data as CTR thus resulting in keyboard being disabled
on boot-up.
This change ensures that keyboard buffer is cleared before adding CTR
data to it.
BUG=b:111228655
BRANCH=poppy,eve,nami
TEST=Verified on nautilus that keyboard is still functional after doing
a reboot from AP shell and continuously pressing keys while system is
booting up in normal mode.
Change-Id: I5cbc904629fbd40b39625e37abccb80c83447d39
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1149561
Commit-Queue: Furquan Shaikh <furquan@chromium.org>
Tested-by: Furquan Shaikh <furquan@chromium.org>
Trybot-Ready: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Philip Chen <philipchen@chromium.org>
-rw-r--r-- | common/keyboard_8042.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/common/keyboard_8042.c b/common/keyboard_8042.c index 3e1836a518..96bfc18aa4 100644 --- a/common/keyboard_8042.c +++ b/common/keyboard_8042.c @@ -667,6 +667,13 @@ static int handle_keyboard_command(uint8_t command, uint8_t *output) switch (command) { case I8042_READ_CMD_BYTE: + /* + * Ensure that the keyboard buffer is cleared before adding + * command byte to it. Since the host is asking for command + * byte, sending it buffered key press data can confuse the + * host and result in it taking incorrect action. + */ + keyboard_clear_buffer(); output[out_len++] = read_ctl_ram(0); break; |