HID: core: replace the collection tree pointers with indices
authorPeter Hutterer <peter.hutterer@who-t.net>
Wed, 9 Jan 2019 03:50:18 +0000 (13:50 +1000)
committerJiri Kosina <jkosina@suse.cz>
Thu, 10 Jan 2019 06:08:18 +0000 (07:08 +0100)
commitee46967fc6e74d412fe1ec15f77fdb8624bde2b0
tree586d3468d91b7059e2f8e9b200c95894501cd4a6
parentcf26057a9441173ad552e90cea3344607075c9ad
HID: core: replace the collection tree pointers with indices

Previously, the pointer to the parent collection was stored. If a device
exceeds 16 collections (HID_DEFAULT_NUM_COLLECTIONS), the array to store
the collections is reallocated, the pointer to the parent collection becomes
invalid.

Replace the pointers with an index-based lookup into the collections array.

Fixes: c53431eb696f3c ("HID: core: store the collections as a basic tree")
Reported-by: Pandruvada, Srinivas <srinivas.pandruvada@intel.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Kyle Pelton <kyle.d.pelton@linux.intel.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-core.c
include/linux/hid.h