]> git.hungrycats.org Git - linux/commitdiff
[PATCH] module removal race fix
authorAndrew Morton <akpm@osdl.org>
Mon, 19 Jan 2004 13:08:26 +0000 (05:08 -0800)
committerLinus Torvalds <torvalds@home.osdl.org>
Mon, 19 Jan 2004 13:08:26 +0000 (05:08 -0800)
From: Rusty Russell <rusty@au1.ibm.com>

Vatsa spotted this: you can remove a module while it's being initialized,
and that will be bad.  Hole was opened when I dropped the sem around the
init routine (which can probe for other modules).

kernel/module.c

index 65f82a3278dd7536f538425ad36d16cbb85dff0d..f3113ff198187d545ac9cb3ef7fa74fabb3fb456 100644 (file)
@@ -687,8 +687,8 @@ sys_delete_module(const char __user *name_user, unsigned int flags)
                goto out;
        }
 
-       /* Already dying? */
-       if (mod->state == MODULE_STATE_GOING) {
+       /* Doing init or already dying? */
+       if (mod->state != MODULE_STATE_LIVE) {
                /* FIXME: if (force), slam module count and wake up
                    waiter --RR */
                DEBUGP("%s already dying\n", mod->name);