diff options
| author | Rusty Russell <rusty@rustcorp.com.au> | 2003-02-25 02:26:20 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.transmeta.com> | 2003-02-25 02:26:20 -0800 |
| commit | 69508a7cd793db94c8af3e221802a3bb0d9a611f (patch) | |
| tree | acc969dd77f7bc9b72ba654c49ccd38c3ac34366 /kernel | |
| parent | f9970fe9e9e735867f6e8d81196aea1fc58f0951 (diff) | |
[PATCH] Modules race fix
Bob Miller points out that the try_module_get in use_module() can, of
course, fail. Secondly, there is a race between setting the module
live, and a simultaneous removal of it.
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/module.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/kernel/module.c b/kernel/module.c index 00d8b07c4fd1..cf8d8cb01022 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -173,16 +173,19 @@ static int use_module(struct module *a, struct module *b) struct module_use *use; if (b == NULL || already_uses(a, b)) return 1; + if (!strong_try_module_get(b)) + return 0; + DEBUGP("Allocating new usage for %s.\n", a->name); use = kmalloc(sizeof(*use), GFP_ATOMIC); if (!use) { printk("%s: out of memory loading\n", a->name); + module_put(b); return 0; } use->module_which_uses = a; list_add(&use->list, &b->modules_which_use_me); - try_module_get(b); /* Can't fail */ return 1; } @@ -1456,10 +1459,12 @@ sys_init_module(void *umod, } /* Now it's a first class citizen! */ + down(&module_mutex); mod->state = MODULE_STATE_LIVE; module_free(mod, mod->module_init); mod->module_init = NULL; mod->init_size = 0; + up(&module_mutex); return 0; } |
