Commit 742e4b630895d751812b0682750db76c8072bf37
1 parent
f865c35224
Exists in
master
and in
4 other branches
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>
Showing 1 changed file with 11 additions and 4 deletions Side-by-side Diff
drivers/watchdog/jz4740_wdt.c
... | ... | @@ -130,11 +130,18 @@ |
130 | 130 | size_t len, loff_t *ppos) |
131 | 131 | { |
132 | 132 | if (len) { |
133 | - if (data[len-1] == 'V') | |
134 | - set_bit(WDT_OK_TO_CLOSE, &jz4740_wdt.status); | |
135 | - else | |
136 | - clear_bit(WDT_OK_TO_CLOSE, &jz4740_wdt.status); | |
133 | + size_t i; | |
137 | 134 | |
135 | + clear_bit(WDT_OK_TO_CLOSE, &jz4740_wdt.status); | |
136 | + for (i = 0; i != len; i++) { | |
137 | + char c; | |
138 | + | |
139 | + if (get_user(c, data + i)) | |
140 | + return -EFAULT; | |
141 | + | |
142 | + if (c == 'V') | |
143 | + set_bit(WDT_OK_TO_CLOSE, &jz4740_wdt.status); | |
144 | + } | |
138 | 145 | jz4740_wdt_service(); |
139 | 146 | } |
140 | 147 |