Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 200126
b: refs/heads/master
c: 3bafeb6
h: refs/heads/master
v: v3
  • Loading branch information
Linus Torvalds authored and Rusty Russell committed Jun 5, 2010
1 parent 9a175e4 commit f07a3c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 75676500f8298f0ee89db12db97294883c4b768e
refs/heads/master: 3bafeb6247042dcbb72b0141ec7c7107de9f0b99
12 changes: 7 additions & 5 deletions trunk/kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -2226,11 +2226,6 @@ static noinline struct module *load_module(void __user *umod,
goto free_mod;
}

if (find_module(mod->name)) {
err = -EEXIST;
goto free_mod;
}

mod->state = MODULE_STATE_COMING;

/* Allow arches to frob section contents and sizes. */
Expand Down Expand Up @@ -2509,6 +2504,12 @@ static noinline struct module *load_module(void __user *umod,
* The mutex protects against concurrent writers.
*/
mutex_lock(&module_mutex);
if (find_module(mod->name)) {
err = -EEXIST;
/* This will also unlock the mutex */
goto already_exists;
}

list_add_rcu(&mod->list, &modules);
mutex_unlock(&module_mutex);

Expand All @@ -2535,6 +2536,7 @@ static noinline struct module *load_module(void __user *umod,
mutex_lock(&module_mutex);
/* Unlink carefully: kallsyms could be walking list. */
list_del_rcu(&mod->list);
already_exists:
mutex_unlock(&module_mutex);
synchronize_sched();
module_arch_cleanup(mod);
Expand Down

0 comments on commit f07a3c0

Please sign in to comment.