Skip to content

Commit

Permalink
HID: wiimote: discard invalid EXT data reports
Browse files Browse the repository at this point in the history
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 <dh.herrmann@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
David Herrmann authored and Jiri Kosina committed Jun 3, 2013
1 parent ee286c2 commit 876727e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drivers/hid/hid-wiimote-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 876727e

Please sign in to comment.