Skip to content

Commit 7ad8148

Browse files
Dan CarpenterJiri Kosina
authored andcommitted
HID: roccat: prevent an out of bounds read in kovaplus_profile_activated()
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: 0e70f97 ("HID: roccat: Add support for Kova[+] mouse") Signed-off-by: Dan Carpenter <[email protected]> Acked-by: Silvan Jegen <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 7cb4774 commit 7ad8148

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/hid/hid-roccat-kovaplus.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ static uint kovaplus_convert_event_cpi(uint value)
3737
static void kovaplus_profile_activated(struct kovaplus_device *kovaplus,
3838
uint new_profile_index)
3939
{
40+
if (new_profile_index >= ARRAY_SIZE(kovaplus->profile_settings))
41+
return;
4042
kovaplus->actual_profile = new_profile_index;
4143
kovaplus->actual_cpi = kovaplus->profile_settings[new_profile_index].cpi_startup_level;
4244
kovaplus->actual_x_sensitivity = kovaplus->profile_settings[new_profile_index].sensitivity_x;

0 commit comments

Comments
 (0)