diff options
| -rw-r--r-- | drivers/hid/hid-roccat-pyra.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/hid/hid-roccat-pyra.c b/drivers/hid/hid-roccat-pyra.c index 1a07e07d99a0..47d7e74231e5 100644 --- a/drivers/hid/hid-roccat-pyra.c +++ b/drivers/hid/hid-roccat-pyra.c | |||
| @@ -35,6 +35,8 @@ static struct class *pyra_class; | |||
| 35 | static void profile_activated(struct pyra_device *pyra, | 35 | static void profile_activated(struct pyra_device *pyra, |
| 36 | unsigned int new_profile) | 36 | unsigned int new_profile) |
| 37 | { | 37 | { |
| 38 | if (new_profile >= ARRAY_SIZE(pyra->profile_settings)) | ||
| 39 | return; | ||
| 38 | pyra->actual_profile = new_profile; | 40 | pyra->actual_profile = new_profile; |
| 39 | pyra->actual_cpi = pyra->profile_settings[pyra->actual_profile].y_cpi; | 41 | pyra->actual_cpi = pyra->profile_settings[pyra->actual_profile].y_cpi; |
| 40 | } | 42 | } |
| @@ -257,9 +259,11 @@ static ssize_t pyra_sysfs_write_settings(struct file *fp, | |||
| 257 | if (off != 0 || count != PYRA_SIZE_SETTINGS) | 259 | if (off != 0 || count != PYRA_SIZE_SETTINGS) |
| 258 | return -EINVAL; | 260 | return -EINVAL; |
| 259 | 261 | ||
| 260 | mutex_lock(&pyra->pyra_lock); | ||
| 261 | |||
| 262 | settings = (struct pyra_settings const *)buf; | 262 | settings = (struct pyra_settings const *)buf; |
| 263 | if (settings->startup_profile >= ARRAY_SIZE(pyra->profile_settings)) | ||
| 264 | return -EINVAL; | ||
| 265 | |||
| 266 | mutex_lock(&pyra->pyra_lock); | ||
| 263 | 267 | ||
| 264 | retval = pyra_set_settings(usb_dev, settings); | 268 | retval = pyra_set_settings(usb_dev, settings); |
| 265 | if (retval) { | 269 | if (retval) { |
