diff options
| author | kimi <kimi.h.kuparinen@gmail.com> | 2021-03-24 18:50:32 -0400 |
|---|---|---|
| committer | kimi <kimi.h.kuparinen@gmail.com> | 2021-03-24 18:50:32 -0400 |
| commit | e5413ae5b056df9c95cb311dfbc9bf8fa634743f (patch) | |
| tree | 02c56b578fb148168b935929107155a4bb281ae2 | |
| parent | f604339def269c3a8a82dd51a431c831b6945653 (diff) | |
| download | hid-tmff2-e5413ae5b056df9c95cb311dfbc9bf8fa634743f.tar.gz hid-tmff2-e5413ae5b056df9c95cb311dfbc9bf8fa634743f.zip | |
Added check to kstrtouint
| -rw-r--r-- | hid-tmt300rs.c | 30 | ||||
| -rw-r--r-- | hid-tmt300rs.h | 2 |
2 files changed, 28 insertions, 4 deletions
diff --git a/hid-tmt300rs.c b/hid-tmt300rs.c index 639da08..54ace09 100644 --- a/hid-tmt300rs.c +++ b/hid-tmt300rs.c @@ -1058,9 +1058,15 @@ static int t300rs_play(struct input_dev *dev, int effect_id, int value) static ssize_t spring_level_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { + struct hid_device *hdev = to_hid_device(dev); unsigned int value; + int ret; - kstrtouint(buf, 10, &value); + ret = kstrtouint(buf, 0, &value); + if (ret) { + hid_err(hdev, "kstrtouint failed at spring_level_store: %i", ret); + return ret; + } if (value > 100) value = 100; @@ -1084,9 +1090,15 @@ static DEVICE_ATTR_RW(spring_level); static ssize_t damper_level_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { + struct hid_device *hdev = to_hid_device(dev); unsigned int value; + int ret; - kstrtouint(buf, 10, &value); + ret = kstrtouint(buf, 0, &value); + if (ret) { + hid_err(hdev, "kstrtouint failed at damper_level_store: %i", ret); + return ret; + } if (value > 100) value = 100; @@ -1111,9 +1123,15 @@ static DEVICE_ATTR_RW(damper_level); static ssize_t friction_level_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { + struct hid_device *hdev = to_hid_device(dev); unsigned int value; + int ret; - kstrtouint(buf, 10, &value); + ret = kstrtouint(buf, 0, &value); + if (ret) { + hid_err(hdev, "kstrtouint failed at friction_level_store: %i", ret); + return ret; + } if (value > 100) value = 100; @@ -1143,7 +1161,11 @@ static ssize_t range_store(struct device *dev, unsigned int range; int ret, trans; - kstrtouint(buf, 10, &range); + ret = kstrtouint(buf, 0, &range); + if (ret) { + hid_err(hdev, "kstrtouint failed at range_store: %i", ret); + return ret; + } t300rs = t300rs_get_device(hdev); if (!t300rs) { diff --git a/hid-tmt300rs.h b/hid-tmt300rs.h index c3038c5..496ba8f 100644 --- a/hid-tmt300rs.h +++ b/hid-tmt300rs.h @@ -8,6 +8,8 @@ #include <linux/ktime.h> #include <linux/fixp-arith.h> +//#include "hid-ids.h" + #define USB_VENDOR_ID_THRUSTMASTER 0x044f #define T300RS_MAX_EFFECTS 16 |
