Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 204805
b: refs/heads/master
c: 9f85a4b
h: refs/heads/master
i:
  204803: 460ef0f
v: v3
  • Loading branch information
Rusty Russell committed Aug 5, 2010
1 parent 9e68453 commit 1d5dd54
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 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: 40dd2560ec2df21036db9ec8b971f92d98fd1969
refs/heads/master: 9f85a4bbb1cf56f65b3d065a5f88204a757f2325
32 changes: 15 additions & 17 deletions trunk/kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,15 +524,21 @@ static char last_unloaded_module[MODULE_NAME_LEN+1];
EXPORT_TRACEPOINT_SYMBOL(module_get);

/* Init the unload section of the module. */
static void module_unload_init(struct module *mod)
static int module_unload_init(struct module *mod)
{
mod->refptr = alloc_percpu(struct module_ref);
if (!mod->refptr)
return -ENOMEM;

INIT_LIST_HEAD(&mod->source_list);
INIT_LIST_HEAD(&mod->target_list);

/* Hold reference count during initialization. */
__this_cpu_write(mod->refptr->incs, 1);
/* Backwards compatibility macros put refcount during init. */
mod->waiter = current;

return 0;
}

/* Does a already use b? */
Expand Down Expand Up @@ -612,6 +618,8 @@ static void module_unload_free(struct module *mod)
kfree(use);
}
mutex_unlock(&module_mutex);

free_percpu(mod->refptr);
}

#ifdef CONFIG_MODULE_FORCE_UNLOAD
Expand Down Expand Up @@ -885,8 +893,9 @@ int ref_module(struct module *a, struct module *b)
}
EXPORT_SYMBOL_GPL(ref_module);

static inline void module_unload_init(struct module *mod)
static inline int module_unload_init(struct module *mod)
{
return 0;
}
#endif /* CONFIG_MODULE_UNLOAD */

Expand Down Expand Up @@ -1559,10 +1568,7 @@ static void free_module(struct module *mod)
module_free(mod, mod->module_init);
kfree(mod->args);
percpu_modfree(mod);
#if defined(CONFIG_MODULE_UNLOAD)
if (mod->refptr)
free_percpu(mod->refptr);
#endif

/* Free lock-classes: */
lockdep_free_key_range(mod->module_core, mod->core_size);

Expand Down Expand Up @@ -2442,15 +2448,10 @@ static noinline struct module *load_module(void __user *umod,
goto free_percpu;
}

#if defined(CONFIG_MODULE_UNLOAD)
mod->refptr = alloc_percpu(struct module_ref);
if (!mod->refptr) {
err = -ENOMEM;
goto free_init;
}
#endif
/* Now we've moved module, initialize linked lists, etc. */
module_unload_init(mod);
err = module_unload_init(mod);
if (err)
goto free_init;

/* Set up license info based on the info section */
set_license(mod, get_modinfo(sechdrs, infoindex, "license"));
Expand Down Expand Up @@ -2619,10 +2620,7 @@ static noinline struct module *load_module(void __user *umod,
cleanup:
free_modinfo(mod);
module_unload_free(mod);
#if defined(CONFIG_MODULE_UNLOAD)
free_percpu(mod->refptr);
free_init:
#endif
module_free(mod, mod->module_init);
module_free(mod, mod->module_core);
/* mod will be freed with core. Don't access it beyond this line! */
Expand Down

0 comments on commit 1d5dd54

Please sign in to comment.