Skip to contentSkip to conversation

softdog.c (was: Kernel panic after rmmod softdog (2.6.8.1))

PATCH In review Chuck Ebbert 2 participants 2 messages Oct 11, 2004 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 softdog.c (was: Kernel panic after rmmod softdog (2.6.8.1))

Quoted 2 lines · Michael Schierl

today, when testing the software watchdog, I accidentally removed the software watchdog kernel module and got a kernel panic.

Does this fix it? (compiled but not tested)

drivers/char/watchdog/softdog.c Sun Oct 10 23:10:12 2004 renamed from drivers/char/watchdog/softdog.c.orig Sun Oct 10 23:08:24 2004 +4 -2
@@ -135,8 +135,9 @@
 {
        if(test_and_set_bit(0, &timer_alive))
                return -EBUSY;
-       if (nowayout)
-               __module_get(THIS_MODULE);
+
+       __module_get(THIS_MODULE);
+
        /*
         *      Activate timer
         */
@@ -152,6 +153,7 @@
         */
        if (expect_close == 42) {
                softdog_stop();
+               module_put(THIS_MODULE);
        } else {
                printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n");
                softdog_keepalive();

--Chuck Ebbert 11-Oct-04 12:49:45
Current book: Stephen King: Wizard and Glass

maintainer
#1 lore raw
Quoted 16 lines · Chuck Ebbert
drivers/char/watchdog/softdog.c Sun Oct 10 23:10:12 2004 renamed from drivers/char/watchdog/softdog.c.orig Sun Oct 10 23:08:24 2004 +3 -2
@@ -135,8 +135,9 @@
 {
        if(test_and_set_bit(0, &timer_alive))
                return -EBUSY;
-       if (nowayout)
-               __module_get(THIS_MODULE);
+
+       __module_get(THIS_MODULE);
+
        /*
         *      Activate timer
         */

drivers/char/watchdog/softdog.c Sun Oct 10 23:10:12 2004 line 159

Quoted 7 lines
drivers/char/watchdog/softdog.c Sun Oct 10 23:10:12 2004 renamed from drivers/char/watchdog/softdog.c.orig Sun Oct 10 23:08:24 2004 +1 -0
@@ -152,6 +153,7 @@
         */
        if (expect_close == 42) {
                softdog_stop();
+               module_put(THIS_MODULE);
        } else {
                printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n");
                softdog_keepalive();

Now if you do open(), close(), open(), write("V"), close(), the module becomes unremovable, even without nowayout=1. Isn't is possible to simply add a softdog_stop() call to watchdog_exit()?

	Arnd <><