module: fix symbol waiting when module fails before init
authorRusty Russell <rusty@rustcorp.com.au>
Fri, 28 Sep 2012 05:01:03 +0000 (14:31 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Fri, 28 Sep 2012 05:01:03 +0000 (14:31 +0930)
commit6f13909f4fe9652f189b462c6c98767309000321
tree0b56b6817caea8d81c46bbbfe575cd4729ca4a23
parent786d35d45cc40b2a51a18f73e14e135d47fdced7
module: fix symbol waiting when module fails before init

We use resolve_symbol_wait(), which blocks if the module containing
the symbol is still loading.  However:

1) The module_wq we use is only woken after calling the modules' init
   function, but there are other failure paths after the module is
   placed in the linked list where we need to do the same thing.

2) wake_up() only wakes one waiter, and our waitqueue is shared by all
   modules, so we need to wake them all.

3) wake_up_all() doesn't imply a memory barrier: I feel happier calling
   it after we've grabbed and dropped the module_mutex, not just after
   the state assignment.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
kernel/module.c