--- linux-work/kernel/module.c-RCUMOD Tue Nov 27 22:58:19 2001 +++ linux-work/kernel/module.c Mon Jan 7 16:37:54 2002 @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -1065,6 +1066,12 @@ p->next = mod->next; } spin_unlock_irqrestore(&modlist_lock, flags); + + /* Wait for all other cpus to go through a context switch. This + * doesn't plug all module unload races, but at least some of + * them and makes the window much smaller. + */ + synchronize_kernel(); /* And free the memory. */