Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

David Herrmann and committed by
Jiri Kosina
876727ea ee286c2e

+9 -1
+9 -1
drivers/hid/hid-wiimote-core.c
··· 1276 1276 static void handler_ext(struct wiimote_data *wdata, const __u8 *payload, 1277 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 1285 const __u8 *iter, *mods; 1280 1286 const struct wiimod_ops *ops; 1281 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 1292 return; 1285 1293 1286 1294 /* if MP is active, track MP slot hotplugging */