summaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-roccat-kone.c
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2020-10-15 20:41:43 +0200
committerJiri Kosina <jkosina@suse.cz>2020-10-15 20:41:43 +0200
commit9b14b066796d0e8bd05f200f30cb4222f8c0f9f1 (patch)
treee5b3daf993db737ebd6a31f9829cc2d07091e33f /drivers/hid/hid-roccat-kone.c
parentMerge branch 'for-5.10/wiimote' into for-linus (diff)
parentHID: hid-input: fix stylus battery reporting (diff)
downloadlinux-9b14b066796d0e8bd05f200f30cb4222f8c0f9f1.tar.xz
linux-9b14b066796d0e8bd05f200f30cb4222f8c0f9f1.zip
Merge branch 'for-5.9/upstream-fixes' into for-linus
- "heartbeat" report fix for several Wacom devices - Lenovo X1 Tablet support improvements - new device IDs - bounds checking fix in hid-roccat - stylus battery reporting fix
Diffstat (limited to 'drivers/hid/hid-roccat-kone.c')
-rw-r--r--drivers/hid/hid-roccat-kone.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/drivers/hid/hid-roccat-kone.c b/drivers/hid/hid-roccat-kone.c
index 2ff4c8e366ff..1ca64481145e 100644
--- a/drivers/hid/hid-roccat-kone.c
+++ b/drivers/hid/hid-roccat-kone.c
@@ -294,31 +294,40 @@ static ssize_t kone_sysfs_write_settings(struct file *fp, struct kobject *kobj,
struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev));
struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev));
int retval = 0, difference, old_profile;
+ struct kone_settings *settings = (struct kone_settings *)buf;
/* I need to get my data in one piece */
if (off != 0 || count != sizeof(struct kone_settings))
return -EINVAL;
mutex_lock(&kone->kone_lock);
- difference = memcmp(buf, &kone->settings, sizeof(struct kone_settings));
+ difference = memcmp(settings, &kone->settings,
+ sizeof(struct kone_settings));
if (difference) {
- retval = kone_set_settings(usb_dev,
- (struct kone_settings const *)buf);
- if (retval) {
- mutex_unlock(&kone->kone_lock);
- return retval;
+ if (settings->startup_profile < 1 ||
+ settings->startup_profile > 5) {
+ retval = -EINVAL;
+ goto unlock;
}
+ retval = kone_set_settings(usb_dev, settings);
+ if (retval)
+ goto unlock;
+
old_profile = kone->settings.startup_profile;
- memcpy(&kone->settings, buf, sizeof(struct kone_settings));
+ memcpy(&kone->settings, settings, sizeof(struct kone_settings));
kone_profile_activated(kone, kone->settings.startup_profile);
if (kone->settings.startup_profile != old_profile)
kone_profile_report(kone, kone->settings.startup_profile);
}
+unlock:
mutex_unlock(&kone->kone_lock);
+ if (retval)
+ return retval;
+
return sizeof(struct kone_settings);
}
static BIN_ATTR(settings, 0660, kone_sysfs_read_settings,