HID: core: prevent out-of-bound readings
authorAmulya Y <ayarlagadda@nvidia.com>
Thu, 5 Apr 2018 21:49:07 +0000 (14:49 -0700)
committerWinnie Hsu <whsu@nvidia.com>
Thu, 19 Apr 2018 17:01:10 +0000 (10:01 -0700)
commit86ea6e03724ffd7989cc4bdf4b88f4484e3945d9
tree4c45362a86d7a46d86ac5c7b39f2bab0b9f85434
parent1e3475cdd97f5f8b5cde3e5a4780ded2fa108af8
HID: core: prevent out-of-bound readings

Plugging a Logitech DJ receiver with KASAN activated raises a bunch of
out-of-bound readings.

The fields are allocated up to MAX_USAGE, meaning that potentially, we do
not have enough fields to fit the incoming values.
Add checks and silence KASAN.

Bug 1823317
Bug 1935735

Change-Id: Ib3ba92572acbdd4c9ec265e54a45f92606107700
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Gagan Grover <ggrover@nvidia.com>
Signed-off-by: Amulya Yarlagadda <ayarlagadda@nvidia.com>
Reviewed-on: http://git-master/r/1259928
(cherry picked from commit fbc389a39540e177bfa4d49b9214dfe408ef2d4a)
Reviewed-on: https://git-master.nvidia.com/r/1689557
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
Reviewed-by: Winnie Hsu <whsu@nvidia.com>
drivers/hid/hid-core.c