Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 334287
b: refs/heads/master
c: 9bb9c3b
h: refs/heads/master
i:
  334285: db486ab
  334283: 5ad6f2c
  334279: 13715f1
  334271: 0a65238
v: v3
  • Loading branch information
Rusty Russell committed Sep 28, 2012
1 parent c0bcb93 commit 1507654
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 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: 6f13909f4fe9652f189b462c6c98767309000321
refs/heads/master: 9bb9c3be56834653878f766f471fa1c20e562f4c
28 changes: 26 additions & 2 deletions trunk/kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -2845,14 +2845,28 @@ static int post_relocation(struct module *mod, const struct load_info *info)
return module_finalize(info->hdr, info->sechdrs, mod);
}

/* Is this module of this name done loading? No locks held. */
static bool finished_loading(const char *name)
{
struct module *mod;
bool ret;

mutex_lock(&module_mutex);
mod = find_module(name);
ret = !mod || mod->state != MODULE_STATE_COMING;
mutex_unlock(&module_mutex);

return ret;
}

/* Allocate and load the module: note that size of section 0 is always
zero, and we rely on this for optional sections. */
static struct module *load_module(void __user *umod,
unsigned long len,
const char __user *uargs)
{
struct load_info info = { NULL, };
struct module *mod;
struct module *mod, *old;
long err;

pr_debug("load_module: umod=%p, len=%lu, uargs=%p\n",
Expand Down Expand Up @@ -2918,8 +2932,18 @@ static struct module *load_module(void __user *umod,
* function to insert in a way safe to concurrent readers.
* The mutex protects against concurrent writers.
*/
again:
mutex_lock(&module_mutex);
if (find_module(mod->name)) {
if ((old = find_module(mod->name)) != NULL) {
if (old->state == MODULE_STATE_COMING) {
/* Wait in case it fails to load. */
mutex_unlock(&module_mutex);
err = wait_event_interruptible(module_wq,
finished_loading(mod->name));
if (err)
goto free_arch_cleanup;
goto again;
}
err = -EEXIST;
goto unlock;
}
Expand Down

0 comments on commit 1507654

Please sign in to comment.