diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2018-01-10 12:39:03 +0300 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2018-06-01 00:30:10 +0100 |
commit | 50a44c165a67ff0b7e14d221af6cb6c1035aa90a (patch) | |
tree | 5b0703e86031e777efb0885151139876f774ced2 /drivers | |
parent | f064e3c7e09390ea48a5fbda0528e145fba432b5 (diff) |
HID: roccat: prevent an out of bounds read in kovaplus_profile_activated()
commit 7ad81482cad67cbe1ec808490d1ddfc420c42008 upstream.
We get the "new_profile_index" value from the mouse device when we're
handling raw events. Smatch taints it as untrusted data and complains
that we need a bounds check. This seems like a reasonable warning
otherwise there is a small read beyond the end of the array.
Fixes: 0e70f97f257e ("HID: roccat: Add support for Kova[+] mouse")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Silvan Jegen <s.jegen@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hid/hid-roccat-kovaplus.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/hid/hid-roccat-kovaplus.c b/drivers/hid/hid-roccat-kovaplus.c index 112d934132c8..3d37c8971b21 100644 --- a/drivers/hid/hid-roccat-kovaplus.c +++ b/drivers/hid/hid-roccat-kovaplus.c @@ -37,6 +37,8 @@ static uint kovaplus_convert_event_cpi(uint value) static void kovaplus_profile_activated(struct kovaplus_device *kovaplus, uint new_profile_index) { + if (new_profile_index >= ARRAY_SIZE(kovaplus->profile_settings)) + return; kovaplus->actual_profile = new_profile_index; kovaplus->actual_cpi = kovaplus->profile_settings[new_profile_index].cpi_startup_level; kovaplus->actual_x_sensitivity = kovaplus->profile_settings[new_profile_index].sensitivity_x; |