watchdog: jz4740_wdt - fix magic character checking
authorWim Van Sebroeck <wim@iguana.be>
Sun, 16 Jan 2011 19:05:39 +0000 (19:05 +0000)
committerWim Van Sebroeck <wim@iguana.be>
Tue, 15 Mar 2011 16:01:57 +0000 (16:01 +0000)
When writing to /dev/watchdog all characters should be checked
for the magic character 'V'.

Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
drivers/watchdog/jz4740_wdt.c

index 935562322b3838ad7b9345bad586aef598bae9c1..684ba01fb54010a034c7522656f9b891fb22ba3b 100644 (file)
@@ -130,11 +130,18 @@ static ssize_t jz4740_wdt_write(struct file *file, const char *data,
                size_t len, loff_t *ppos)
 {
        if (len) {
-               if (data[len-1] == 'V')
-                       set_bit(WDT_OK_TO_CLOSE, &jz4740_wdt.status);
-               else
-                       clear_bit(WDT_OK_TO_CLOSE, &jz4740_wdt.status);
+               size_t i;
 
+               clear_bit(WDT_OK_TO_CLOSE, &jz4740_wdt.status);
+               for (i = 0; i != len; i++) {
+                       char c;
+
+                       if (get_user(c, data + i))
+                               return -EFAULT;
+
+                       if (c == 'V')
+                               set_bit(WDT_OK_TO_CLOSE, &jz4740_wdt.status);
+               }
                jz4740_wdt_service();
        }
 
This page took 0.054472 seconds and 5 git commands to generate.