diff options
| -rw-r--r-- | drivers/char/watchdog/softdog.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/char/watchdog/softdog.c b/drivers/char/watchdog/softdog.c index 4d7ed931f5c6..20e5eb8667f2 100644 --- a/drivers/char/watchdog/softdog.c +++ b/drivers/char/watchdog/softdog.c | |||
| @@ -77,7 +77,7 @@ static void watchdog_fire(unsigned long); | |||
| 77 | 77 | ||
| 78 | static struct timer_list watchdog_ticktock = | 78 | static struct timer_list watchdog_ticktock = |
| 79 | TIMER_INITIALIZER(watchdog_fire, 0, 0); | 79 | TIMER_INITIALIZER(watchdog_fire, 0, 0); |
| 80 | static unsigned long timer_alive; | 80 | static unsigned long driver_open, orphan_timer; |
| 81 | static char expect_close; | 81 | static char expect_close; |
| 82 | 82 | ||
| 83 | 83 | ||
| @@ -87,6 +87,9 @@ static char expect_close; | |||
| 87 | 87 | ||
| 88 | static void watchdog_fire(unsigned long data) | 88 | static void watchdog_fire(unsigned long data) |
| 89 | { | 89 | { |
| 90 | if (test_and_clear_bit(0, &orphan_timer)) | ||
| 91 | module_put(THIS_MODULE); | ||
| 92 | |||
| 90 | if (soft_noboot) | 93 | if (soft_noboot) |
| 91 | printk(KERN_CRIT PFX "Triggered - Reboot ignored.\n"); | 94 | printk(KERN_CRIT PFX "Triggered - Reboot ignored.\n"); |
| 92 | else | 95 | else |
| @@ -128,9 +131,9 @@ static int softdog_set_heartbeat(int t) | |||
| 128 | 131 | ||
| 129 | static int softdog_open(struct inode *inode, struct file *file) | 132 | static int softdog_open(struct inode *inode, struct file *file) |
| 130 | { | 133 | { |
| 131 | if(test_and_set_bit(0, &timer_alive)) | 134 | if (test_and_set_bit(0, &driver_open)) |
| 132 | return -EBUSY; | 135 | return -EBUSY; |
| 133 | if (nowayout) | 136 | if (!test_and_clear_bit(0, &orphan_timer)) |
| 134 | __module_get(THIS_MODULE); | 137 | __module_get(THIS_MODULE); |
| 135 | /* | 138 | /* |
| 136 | * Activate timer | 139 | * Activate timer |
| @@ -147,11 +150,13 @@ static int softdog_release(struct inode *inode, struct file *file) | |||
| 147 | */ | 150 | */ |
| 148 | if (expect_close == 42) { | 151 | if (expect_close == 42) { |
| 149 | softdog_stop(); | 152 | softdog_stop(); |
| 153 | module_put(THIS_MODULE); | ||
| 150 | } else { | 154 | } else { |
| 151 | printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); | 155 | printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); |
| 156 | set_bit(0, &orphan_timer); | ||
| 152 | softdog_keepalive(); | 157 | softdog_keepalive(); |
| 153 | } | 158 | } |
| 154 | clear_bit(0, &timer_alive); | 159 | clear_bit(0, &driver_open); |
| 155 | expect_close = 0; | 160 | expect_close = 0; |
| 156 | return 0; | 161 | return 0; |
| 157 | } | 162 | } |
