toshiba_acpi: Change touchpad store to check for invalid values
authorAzael Avalos <coproscefalo@gmail.com>
Thu, 11 Sep 2014 03:01:57 +0000 (21:01 -0600)
committerDarren Hart <dvhart@linux.intel.com>
Wed, 17 Sep 2014 20:55:52 +0000 (13:55 -0700)
The function toshiba_touchpad_store is not checking
for invalid values and simply returns silently.

This patch checks for invalid values and returns accordingly.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
drivers/platform/x86/toshiba_acpi.c

index 4c8fa7b72891a67f97aa1462096a09791b5e1d0b..2a84652a4f0eb4d5c3b02fec8ef8fac1f4677bea 100644 (file)
@@ -1343,12 +1343,18 @@ static ssize_t toshiba_touchpad_store(struct device *dev,
 {
        struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev);
        int state;
+       int ret;
 
        /* Set the TouchPad on/off, 0 - Disable | 1 - Enable */
-       if (sscanf(buf, "%i", &state) == 1 && (state == 0 || state == 1)) {
-               if (toshiba_touchpad_set(toshiba, state) < 0)
-                       return -EIO;
-       }
+       ret = kstrtoint(buf, 0, &state);
+       if (ret)
+               return ret;
+       if (state != 0 && state != 1)
+               return -EINVAL;
+
+       ret = toshiba_touchpad_set(toshiba, state);
+       if (ret)
+               return ret;
 
        return count;
 }