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.
/* 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 */
}
/* 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) {
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:
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],");
}
#endif /* CONFIG_MODULE_UNLOAD */
#ifdef CONFIG_OBSOLETE_MODPARM
-static int param_set_byte(const char *val, struct kernel_param *kp)
-{
- char *endp;
- long l;
-
- if (!val) return -EINVAL;
- l = simple_strtol(val, &endp, 0);
- if (endp == val || *endp || ((char)l != l))
- return -EINVAL;
- *((char *)kp->arg) = l;
- return 0;
-}
-
/* Bounds checking done below */
static int obsparm_copy_string(const char *val, struct kernel_param *kp)
{
secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
sechdrs[0].sh_addr = 0;
- /* And these should exist, but gcc whinges if we don't init them */
- symindex = strindex = 0;
-
for (i = 1; i < hdr->e_shnum; i++) {
if (sechdrs[i].sh_type != SHT_NOBITS
&& len < sechdrs[i].sh_offset + sechdrs[i].sh_size)
}
mod = (void *)sechdrs[modindex].sh_addr;
+ if (symindex == 0) {
+ printk(KERN_WARNING "%s: module has no symbols (stripped?)\n",
+ mod->name);
+ err = -ENOEXEC;
+ goto free_hdr;
+ }
+
/* Optional sections */
exportindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab");
gplindex = find_sec(hdr, sechdrs, secstrings, "__ksymtab_gpl");
const char __user *uargs)
{
struct module *mod;
- int ret;
+ int ret = 0;
/* Must have permission */
if (!capable(CAP_SYS_MODULE))
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. */