Skip to contentSkip to conversation

Input: vsxxxaa - fix code dropping bytes from queue

PATCH In review Dmitry Torokhov 2 participants 2 messages Oct 24, 2014 – Oct 25, 2014

Subsystems (2)
lore
Share & tools
lore

Dmitry Torokhov

author maintainer
#0 lore raw

PATCH 1/1 Input: vsxxxaa - fix code dropping bytes from queue

I believe the intent of the code was to drop oldest bytes from the queue, not the latest if we drop one byte and both latest and some oldest of we are dropping more than one.

---
 drivers/input/mouse/vsxxxaa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/mouse/vsxxxaa.c +1 -1
index 3829823..abd4944 100644
@@ -128,7 +128,7 @@ static void vsxxxaa_drop_bytes(struct vsxxxaa *mouse, int num)
 	if (num >= mouse->count) {
 		mouse->count = 0;
 	} else {
-		memmove(mouse->buf, mouse->buf + num - 1, BUFLEN - num);
+		memmove(mouse->buf, mouse->buf + num, BUFLEN - num);
 		mouse->count -= num;
 	}
 }
Signature · 5 lines
2.1.0.rc2.206.gedb03e5


-- 
Dmitry
Acked-by on v1 1/1
#1 lore raw
Quoted 14 lines · Dmitry Torokhov

I believe the intent of the code was to drop oldest bytes from the queue, not the latest if we drop one byte and both latest and some oldest of we are dropping more than one.

---
 drivers/input/mouse/vsxxxaa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/mouse/vsxxxaa.c +0 -0
index 3829823..abd4944 100644

drivers/input/mouse/vsxxxaa.c static void vsxxxaa_drop_bytes(struct vsxxxaa *mouse, int num) · line 134

Quoted 8 lines
drivers/input/mouse/vsxxxaa.c +1 -1
@@ -128,7 +128,7 @@ static void vsxxxaa_drop_bytes(struct vsxxxaa *mouse, int num)
 	if (num >= mouse->count) {
 		mouse->count = 0;
 	} else {
-		memmove(mouse->buf, mouse->buf + num - 1, BUFLEN - num);
+		memmove(mouse->buf, mouse->buf + num, BUFLEN - num);
 		mouse->count -= num;
 	}
 }

Good catch! I fucked up the error recovery path.

MfG, JBG

Signature · 3 lines
      Jan-Benedict Glaw      [email protected]              +49-172-7608481
Signature of:                     Eine Freie Meinung in einem Freien Kopf
the second  :                   für einen Freien Staat voll Freier Bürger.