Skip to content

Commit

Permalink
watchdog: jz4740_wdt - fix magic character checking
Browse files Browse the repository at this point in the history
When writing to /dev/watchdog all characters should be checked
for the magic character 'V'.

Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
  • Loading branch information
Wim Van Sebroeck committed Mar 15, 2011
1 parent f865c35 commit 742e4b6
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions drivers/watchdog/jz4740_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit 742e4b6

Please sign in to comment.