X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fhid%2Fhid-roccat-pyra.c;h=13b40a0c46edca215970b65c81beec50bea125a8;hb=aa869750c78648d1ccae1a7e23239e64cc0859c9;hp=df05c1b1064ff18e304d2f08f3c59d920dceda9b;hpb=b4fdcb02f1e39c27058a885905bd0277370ba441;p=pandora-kernel.git diff --git a/drivers/hid/hid-roccat-pyra.c b/drivers/hid/hid-roccat-pyra.c index df05c1b1064f..13b40a0c46ed 100644 --- a/drivers/hid/hid-roccat-pyra.c +++ b/drivers/hid/hid-roccat-pyra.c @@ -35,6 +35,8 @@ static struct class *pyra_class; static void profile_activated(struct pyra_device *pyra, unsigned int new_profile) { + if (new_profile >= ARRAY_SIZE(pyra->profile_settings)) + return; pyra->actual_profile = new_profile; pyra->actual_cpi = pyra->profile_settings[pyra->actual_profile].y_cpi; } @@ -303,6 +305,10 @@ static ssize_t pyra_sysfs_write_settings(struct file *fp, if (off != 0 || count != sizeof(struct pyra_settings)) return -EINVAL; + if (((struct pyra_settings const *)buf)->startup_profile >= + ARRAY_SIZE(pyra->profile_settings)) + return -EINVAL; + mutex_lock(&pyra->pyra_lock); difference = memcmp(buf, &pyra->settings, sizeof(struct pyra_settings)); if (difference) {