From: David Herrmann Date: Sun, 26 May 2013 20:55:03 +0000 (+0200) Subject: HID: wiimote: discard invalid EXT data reports X-Git-Tag: upstream/snapshot3+hdmi~4779^2^3~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=876727eabf3f224beb5f9b3bbcec2fb891faa89d;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git HID: wiimote: discard invalid EXT data reports If an extension device isn't initialized properly, or during hardware initialization, a device might send extension data which is all 0xff. This is ambigious because this is also a valid normal data report. But it is impossible, under normal conditions, to trigger valid reports with all 0xff. Hence, we can safely ignore them. Signed-off-by: David Herrmann Signed-off-by: Jiri Kosina --- diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c index ea00030..e0ac84b 100644 --- a/drivers/hid/hid-wiimote-core.c +++ b/drivers/hid/hid-wiimote-core.c @@ -1276,11 +1276,19 @@ static bool valid_ext_handler(const struct wiimod_ops *ops, size_t len) static void handler_ext(struct wiimote_data *wdata, const __u8 *payload, size_t len) { + static const __u8 invalid[21] = { 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, + 0xff }; const __u8 *iter, *mods; const struct wiimod_ops *ops; bool is_mp; - if (len < 6) + if (len > 21) + len = 21; + if (len < 6 || !memcmp(payload, invalid, len)) return; /* if MP is active, track MP slot hotplugging */