HID: core: prevent out-of-bound readings
authorAmulya Y <ayarlagadda@nvidia.com>
Fri, 6 Apr 2018 22:48:49 +0000 (15:48 -0700)
committerWinnie Hsu <whsu@nvidia.com>
Thu, 19 Apr 2018 17:58:40 +0000 (10:58 -0700)
commite592ed68b3c3c27d74d5592f99b423596755263a
tree34fc0479c1250637ab53b1cbd68f06572d7b0de9
parentac43b10b632fac3412f18100e463e2129318bd3a
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/1690285
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
Reviewed-by: Winnie Hsu <whsu@nvidia.com>
drivers/hid/hid-core.c