diff options
| author | Brian Gerst <bgerst@quark.didntduck.org> | 2004-09-07 17:53:23 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-09-07 17:53:23 -0700 |
| commit | 2390fd2b793dd6bcde7f7c6738ba2e6ba51a36d9 (patch) | |
| tree | 36d2c680363ba00ddcf857d1d228a546f52a5651 /kernel | |
| parent | 2bb56b4e432b8192633bf98b9d6bbb68554439d0 (diff) | |
[PATCH] Remove in-kernel init_module/cleanup_module stubs
This patch removes the default stubs for init_module and cleanup_module,
and checks for NULL instead. It changes modpost to only create references
to those functions if they actually exist.
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/module.c | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/kernel/module.c b/kernel/module.c index 8c17a4ce0707..8b3726655a87 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -89,13 +89,6 @@ static inline int strong_try_module_get(struct module *mod) return try_module_get(mod); } -/* Stub function for modules which don't have an initfn */ -int init_module(void) -{ - return 0; -} -EXPORT_SYMBOL(init_module); - /* A thread that wants to hold a reference to a module only while it * is running can call ths to safely exit. * nfsd and lockd use this. @@ -529,12 +522,6 @@ EXPORT_SYMBOL(module_refcount); /* This exists whether we can unload or not */ static void free_module(struct module *mod); -/* Stub function for modules which don't have an exitfn */ -void cleanup_module(void) -{ -} -EXPORT_SYMBOL(cleanup_module); - static void wait_for_zero_refcount(struct module *mod) { /* Since we might sleep for some time, drop the semaphore first */ @@ -589,7 +576,7 @@ sys_delete_module(const char __user *name_user, unsigned int flags) } /* If it has an init func, it must have an exit func to unload */ - if ((mod->init != init_module && mod->exit == cleanup_module) + if ((mod->init != NULL && mod->exit == NULL) || mod->unsafe) { forced = try_force(flags); if (!forced) { @@ -610,9 +597,11 @@ sys_delete_module(const char __user *name_user, unsigned int flags) wait_for_zero_refcount(mod); /* Final destruction now noone is using it. */ - up(&module_mutex); - mod->exit(); - down(&module_mutex); + if (mod->exit != NULL) { + up(&module_mutex); + mod->exit(); + down(&module_mutex); + } free_module(mod); out: @@ -639,7 +628,7 @@ static void print_unload_info(struct seq_file *m, struct module *mod) seq_printf(m, "[unsafe],"); } - if (mod->init != init_module && mod->exit == cleanup_module) { + if (mod->init != NULL && mod->exit == NULL) { printed_something = 1; seq_printf(m, "[permanent],"); } @@ -1836,7 +1825,7 @@ sys_init_module(void __user *umod, const char __user *uargs) { struct module *mod; - int ret; + int ret = 0; /* Must have permission */ if (!capable(CAP_SYS_MODULE)) @@ -1875,7 +1864,8 @@ sys_init_module(void __user *umod, up(¬ify_mutex); /* Start the module */ - ret = mod->init(); + if (mod->init != NULL) + ret = mod->init(); if (ret < 0) { /* Init routine failed: abort. Try to protect us from buggy refcounters. */ |
