diff options
author | Dmitry Torokhov <dtor@insightbb.com> | 2006-07-06 23:55:00 -0400 |
---|---|---|
committer | Dmitry Torokhov <dtor@insightbb.com> | 2006-07-06 23:55:00 -0400 |
commit | 8d64d3722c6abbb43bccd518ececc5559e1962b4 (patch) | |
tree | c276cfd7db4e10bb3544937c286512b0610c1f17 /drivers/input/joystick | |
parent | 95349fe8144b7d18f04bdca1c2d3fb85789de4fb (diff) |
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.c | 18 |
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) | |||
222 | int err = 0; | 222 | int err = 0; |
223 | struct iforce_core_effect* core_effect; | 223 | struct iforce_core_effect* core_effect; |
224 | 224 | ||
225 | /* Check who is trying to erase this effect */ | ||
226 | if (iforce->core_effects[effect_id].owner != current->pid) { | ||
227 | printk(KERN_WARNING "iforce-main.c: %d tried to erase an effect belonging to %d\n", current->pid, iforce->core_effects[effect_id].owner); | ||
228 | return -EACCES; | ||
229 | } | ||
230 | |||
231 | if (effect_id < 0 || effect_id >= FF_EFFECTS_MAX) | 225 | if (effect_id < 0 || effect_id >= FF_EFFECTS_MAX) |
232 | return -EINVAL; | 226 | return -EINVAL; |
233 | 227 | ||
234 | core_effect = iforce->core_effects + effect_id; | 228 | core_effect = &iforce->core_effects[effect_id]; |
229 | |||
230 | /* Check who is trying to erase this effect */ | ||
231 | if (core_effect->owner != current->pid) { | ||
232 | printk(KERN_WARNING "iforce-main.c: %d tried to erase an effect belonging to %d\n", current->pid, core_effect->owner); | ||
233 | return -EACCES; | ||
234 | } | ||
235 | 235 | ||
236 | if (test_bit(FF_MOD1_IS_USED, core_effect->flags)) | 236 | if (test_bit(FF_MOD1_IS_USED, core_effect->flags)) |
237 | err = release_resource(&(iforce->core_effects[effect_id].mod1_chunk)); | 237 | err = release_resource(&core_effect->mod1_chunk); |
238 | 238 | ||
239 | if (!err && test_bit(FF_MOD2_IS_USED, core_effect->flags)) | 239 | if (!err && test_bit(FF_MOD2_IS_USED, core_effect->flags)) |
240 | err = release_resource(&(iforce->core_effects[effect_id].mod2_chunk)); | 240 | err = release_resource(&core_effect->mod2_chunk); |
241 | 241 | ||
242 | /*TODO: remember to change that if more FF_MOD* bits are added */ | 242 | /*TODO: remember to change that if more FF_MOD* bits are added */ |
243 | core_effect->flags[0] = 0; | 243 | core_effect->flags[0] = 0; |