summaryrefslogtreecommitdiffstats
path: root/drivers/input/joystick
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor@insightbb.com>2006-07-06 23:55:00 -0400
committerDmitry Torokhov <dtor@insightbb.com>2006-07-06 23:55:00 -0400
commit8d64d3722c6abbb43bccd518ececc5559e1962b4 (patch)
treec276cfd7db4e10bb3544937c286512b0610c1f17 /drivers/input/joystick
parent95349fe8144b7d18f04bdca1c2d3fb85789de4fb (diff)
downloadlinux-stable-8d64d3722c6abbb43bccd518ececc5559e1962b4.tar.gz
linux-stable-8d64d3722c6abbb43bccd518ececc5559e1962b4.tar.bz2
linux-stable-8d64d3722c6abbb43bccd518ececc5559e1962b4.zip
Input: iforce - check array bounds before accessing elements
Fixes Coverity #id 864 Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/joystick')
-rw-r--r--drivers/input/joystick/iforce/iforce-main.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/input/joystick/iforce/iforce-main.c b/drivers/input/joystick/iforce/iforce-main.c
index 6d99e3c37884..dc6cfea23866 100644
--- a/drivers/input/joystick/iforce/iforce-main.c
+++ b/drivers/input/joystick/iforce/iforce-main.c
@@ -222,22 +222,22 @@ static int iforce_erase_effect(struct input_dev *dev, int effect_id)
int err = 0;
struct iforce_core_effect* core_effect;
- /* Check who is trying to erase this effect */
- if (iforce->core_effects[effect_id].owner != current->pid) {
- printk(KERN_WARNING "iforce-main.c: %d tried to erase an effect belonging to %d\n", current->pid, iforce->core_effects[effect_id].owner);
- return -EACCES;
- }
-
if (effect_id < 0 || effect_id >= FF_EFFECTS_MAX)
return -EINVAL;
- core_effect = iforce->core_effects + effect_id;
+ core_effect = &iforce->core_effects[effect_id];
+
+ /* Check who is trying to erase this effect */
+ if (core_effect->owner != current->pid) {
+ printk(KERN_WARNING "iforce-main.c: %d tried to erase an effect belonging to %d\n", current->pid, core_effect->owner);
+ return -EACCES;
+ }
if (test_bit(FF_MOD1_IS_USED, core_effect->flags))
- err = release_resource(&(iforce->core_effects[effect_id].mod1_chunk));
+ err = release_resource(&core_effect->mod1_chunk);
if (!err && test_bit(FF_MOD2_IS_USED, core_effect->flags))
- err = release_resource(&(iforce->core_effects[effect_id].mod2_chunk));
+ err = release_resource(&core_effect->mod2_chunk);
/*TODO: remember to change that if more FF_MOD* bits are added */
core_effect->flags[0] = 0;