36 lines
932 B
Diff
36 lines
932 B
Diff
|
|
From 0a54d68547df3f276dc242b52d54e8549d0a84a0 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Chuan Zheng <zhengchuan@huawei.com>
|
||
|
|
Date: Wed, 9 Feb 2022 11:21:28 +0800
|
||
|
|
Subject: [PATCH] ps2: fix oob in ps2 kbd
|
||
|
|
|
||
|
|
fix oob in ps2 kbd
|
||
|
|
---
|
||
|
|
hw/input/ps2.c | 4 ++--
|
||
|
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/hw/input/ps2.c b/hw/input/ps2.c
|
||
|
|
index c8fd23cf36..b647561069 100644
|
||
|
|
--- a/hw/input/ps2.c
|
||
|
|
+++ b/hw/input/ps2.c
|
||
|
|
@@ -167,7 +167,7 @@ void ps2_queue_noirq(PS2State *s, int b)
|
||
|
|
}
|
||
|
|
|
||
|
|
q->data[q->wptr] = b;
|
||
|
|
- if (++q->wptr == PS2_BUFFER_SIZE) {
|
||
|
|
+ if (++q->wptr >= PS2_BUFFER_SIZE) {
|
||
|
|
q->wptr = 0;
|
||
|
|
}
|
||
|
|
q->count++;
|
||
|
|
@@ -557,7 +557,7 @@ uint32_t ps2_read_data(PS2State *s)
|
||
|
|
val = q->data[index];
|
||
|
|
} else {
|
||
|
|
val = q->data[q->rptr];
|
||
|
|
- if (++q->rptr == PS2_BUFFER_SIZE) {
|
||
|
|
+ if (++q->rptr >= PS2_BUFFER_SIZE) {
|
||
|
|
q->rptr = 0;
|
||
|
|
}
|
||
|
|
q->count--;
|
||
|
|
--
|
||
|
|
2.27.0
|
||
|
|
|