
From: Rusty Russell <rusty@rustcorp.com.au>

mod->waiter needs to be set before we try to stop the module: setting it in
__try_stop_module means it gets set to the kthread, not rmmod.


---

 25-akpm/kernel/module.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletion(-)

diff -puN kernel/module.c~set-mod-waiter-before-calling-stop_machine kernel/module.c
--- 25/kernel/module.c~set-mod-waiter-before-calling-stop_machine	2004-04-03 02:59:57.801565768 -0800
+++ 25-akpm/kernel/module.c	2004-04-03 02:59:57.806565008 -0800
@@ -493,7 +493,6 @@ static inline int __try_stop_module(void
 	}
 
 	/* Mark it as dying. */
-	sref->mod->waiter = current;
 	sref->mod->state = MODULE_STATE_GOING;
 	return 0;
 }
@@ -588,6 +587,9 @@ sys_delete_module(const char __user *nam
 		}
 	}
 
+	/* Set this up before setting mod->state */
+	mod->waiter = current;
+
 	/* Stop the machine so refcounts can't move and disable module. */
 	ret = try_stop_module(mod, flags, &forced);
 

_
