aboutsummaryrefslogtreecommitdiff
path: root/drivers/watchdog
diff options
context:
space:
mode:
authorWim Van Sebroeck <wim@iguana.be>2011-01-16 19:05:39 +0000
committerWim Van Sebroeck <wim@iguana.be>2011-03-15 16:01:57 +0000
commit742e4b630895d751812b0682750db76c8072bf37 (patch)
tree0a2b75d932e1f924898de3584e5ed1b4b671b0b9 /drivers/watchdog
parentf865c35224bb310a1b464062ae1e946d261708e3 (diff)
watchdog: jz4740_wdt - fix magic character checking
When writing to /dev/watchdog all characters should be checked for the magic character 'V'. Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r--drivers/watchdog/jz4740_wdt.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/watchdog/jz4740_wdt.c b/drivers/watchdog/jz4740_wdt.c
index 935562322b3..684ba01fb54 100644
--- a/drivers/watchdog/jz4740_wdt.c
+++ b/drivers/watchdog/jz4740_wdt.c
@@ -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();
}