DORMANTno replies

[PATCH 2/4] xpad.c Check for data length and ignore packet if it is smaller

From: Jan Kratochvil <hidden>
Date: 2007-06-03 14:01:36
Subsystem: input (keyboard, mouse, joystick, touchscreen) drivers, the rest · Maintainers: Dmitry Torokhov, Linus Torvalds

xpad360_process_packet will ignore packets smaller then 20 bytes. For example 
notification about headset connection is only 3 bytes long.

Signed-off-by: Jan Kratochvil <redacted>
---
  drivers/input/joystick/xpad.c |    5 +++++
  1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 56d5e3e..15f9877 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -268,12 +268,17 @@ static void xpad_process_packet(struct u
   *
   *	The used report descriptor was taken from:
   *		http://www.free60.org/wiki/Gamepad
+ *     Packet length for valid data is 20 bytes.
   */

  static void xpad360_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data)
  {
  	struct input_dev *dev = xpad->dev;

+	/* valid data */
+	if (data[1] < 20)
+		return;
+
  	/* digital pad */
  	if (xpad->dpad_mapping == MAP_DPAD_TO_AXES) {
  		input_report_abs(dev, ABS_HAT0X, !!(data[2] & 0x01) - !!((data[2] & 0x08) >> 3));
-- 
1.4.3.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help