Re: [PATCH v2 5/5] toshiba_acpi: Change touchpad store to check for invalid values

2014-09-11 Thread Darren Hart
On Wed, Sep 10, 2014 at 09:01:57PM -0600, Azael Avalos wrote:
> 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 

Queued, thanks Azael!

-- 
Darren Hart
Intel Open Source Technology Center
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 5/5] toshiba_acpi: Change touchpad store to check for invalid values

2014-09-10 Thread Azael Avalos
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 
---
 drivers/platform/x86/toshiba_acpi.c | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/toshiba_acpi.c 
b/drivers/platform/x86/toshiba_acpi.c
index 08147c5..5a2324d 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -1429,12 +1429,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;
 }
-- 
2.0.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/