diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2013-05-26 16:55:03 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2013-06-03 05:07:07 -0400 |
commit | 876727eabf3f224beb5f9b3bbcec2fb891faa89d (patch) | |
tree | d53ca742c2ac7c1af4ecbf48250d794a77885c01 /drivers/hid | |
parent | ee286c2e80547d87ed4e55c00709783aa2261848 (diff) |
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 <dh.herrmann@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r-- | drivers/hid/hid-wiimote-core.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c index ea00030defd6..e0ac84b2f74b 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) | |||
1276 | static void handler_ext(struct wiimote_data *wdata, const __u8 *payload, | 1276 | static void handler_ext(struct wiimote_data *wdata, const __u8 *payload, |
1277 | size_t len) | 1277 | size_t len) |
1278 | { | 1278 | { |
1279 | static const __u8 invalid[21] = { 0xff, 0xff, 0xff, 0xff, | ||
1280 | 0xff, 0xff, 0xff, 0xff, | ||
1281 | 0xff, 0xff, 0xff, 0xff, | ||
1282 | 0xff, 0xff, 0xff, 0xff, | ||
1283 | 0xff, 0xff, 0xff, 0xff, | ||
1284 | 0xff }; | ||
1279 | const __u8 *iter, *mods; | 1285 | const __u8 *iter, *mods; |
1280 | const struct wiimod_ops *ops; | 1286 | const struct wiimod_ops *ops; |
1281 | bool is_mp; | 1287 | bool is_mp; |
1282 | 1288 | ||
1283 | if (len < 6) | 1289 | if (len > 21) |
1290 | len = 21; | ||
1291 | if (len < 6 || !memcmp(payload, invalid, len)) | ||
1284 | return; | 1292 | return; |
1285 | 1293 | ||
1286 | /* if MP is active, track MP slot hotplugging */ | 1294 | /* if MP is active, track MP slot hotplugging */ |