diff options
Diffstat (limited to 'kernel/module.c')
-rw-r--r-- | kernel/module.c | 61 |
1 files changed, 22 insertions, 39 deletions
diff --git a/kernel/module.c b/kernel/module.c index a8014bfb5a4e..333fbcc96978 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -180,8 +180,6 @@ extern const struct kernel_symbol __start___ksymtab_gpl[]; | |||
180 | extern const struct kernel_symbol __stop___ksymtab_gpl[]; | 180 | extern const struct kernel_symbol __stop___ksymtab_gpl[]; |
181 | extern const struct kernel_symbol __start___ksymtab_gpl_future[]; | 181 | extern const struct kernel_symbol __start___ksymtab_gpl_future[]; |
182 | extern const struct kernel_symbol __stop___ksymtab_gpl_future[]; | 182 | extern const struct kernel_symbol __stop___ksymtab_gpl_future[]; |
183 | extern const struct kernel_symbol __start___ksymtab_gpl_future[]; | ||
184 | extern const struct kernel_symbol __stop___ksymtab_gpl_future[]; | ||
185 | extern const unsigned long __start___kcrctab[]; | 183 | extern const unsigned long __start___kcrctab[]; |
186 | extern const unsigned long __start___kcrctab_gpl[]; | 184 | extern const unsigned long __start___kcrctab_gpl[]; |
187 | extern const unsigned long __start___kcrctab_gpl_future[]; | 185 | extern const unsigned long __start___kcrctab_gpl_future[]; |
@@ -565,26 +563,33 @@ int use_module(struct module *a, struct module *b) | |||
565 | struct module_use *use; | 563 | struct module_use *use; |
566 | int no_warn, err; | 564 | int no_warn, err; |
567 | 565 | ||
568 | if (b == NULL || already_uses(a, b)) | 566 | if (b == NULL || already_uses(a, b)) return 1; |
569 | return 0; | ||
570 | 567 | ||
571 | /* If we're interrupted or time out, we fail. */ | 568 | /* If we're interrupted or time out, we fail. */ |
572 | err = strong_try_module_get(b); | 569 | if (wait_event_interruptible_timeout( |
570 | module_wq, (err = strong_try_module_get(b)) != -EBUSY, | ||
571 | 30 * HZ) <= 0) { | ||
572 | printk("%s: gave up waiting for init of module %s.\n", | ||
573 | a->name, b->name); | ||
574 | return 0; | ||
575 | } | ||
576 | |||
577 | /* If strong_try_module_get() returned a different error, we fail. */ | ||
573 | if (err) | 578 | if (err) |
574 | return err; | 579 | return 0; |
575 | 580 | ||
576 | DEBUGP("Allocating new usage for %s.\n", a->name); | 581 | DEBUGP("Allocating new usage for %s.\n", a->name); |
577 | use = kmalloc(sizeof(*use), GFP_ATOMIC); | 582 | use = kmalloc(sizeof(*use), GFP_ATOMIC); |
578 | if (!use) { | 583 | if (!use) { |
579 | printk("%s: out of memory loading\n", a->name); | 584 | printk("%s: out of memory loading\n", a->name); |
580 | module_put(b); | 585 | module_put(b); |
581 | return -ENOMEM; | 586 | return 0; |
582 | } | 587 | } |
583 | 588 | ||
584 | use->module_which_uses = a; | 589 | use->module_which_uses = a; |
585 | list_add(&use->list, &b->modules_which_use_me); | 590 | list_add(&use->list, &b->modules_which_use_me); |
586 | no_warn = sysfs_create_link(b->holders_dir, &a->mkobj.kobj, a->name); | 591 | no_warn = sysfs_create_link(b->holders_dir, &a->mkobj.kobj, a->name); |
587 | return 0; | 592 | return 1; |
588 | } | 593 | } |
589 | EXPORT_SYMBOL_GPL(use_module); | 594 | EXPORT_SYMBOL_GPL(use_module); |
590 | 595 | ||
@@ -877,7 +882,7 @@ static inline void module_unload_free(struct module *mod) | |||
877 | 882 | ||
878 | int use_module(struct module *a, struct module *b) | 883 | int use_module(struct module *a, struct module *b) |
879 | { | 884 | { |
880 | return strong_try_module_get(b); | 885 | return strong_try_module_get(b) == 0; |
881 | } | 886 | } |
882 | EXPORT_SYMBOL_GPL(use_module); | 887 | EXPORT_SYMBOL_GPL(use_module); |
883 | 888 | ||
@@ -1048,39 +1053,17 @@ static const struct kernel_symbol *resolve_symbol(Elf_Shdr *sechdrs, | |||
1048 | struct module *owner; | 1053 | struct module *owner; |
1049 | const struct kernel_symbol *sym; | 1054 | const struct kernel_symbol *sym; |
1050 | const unsigned long *crc; | 1055 | const unsigned long *crc; |
1051 | DEFINE_WAIT(wait); | ||
1052 | int err; | ||
1053 | long timeleft = 30 * HZ; | ||
1054 | 1056 | ||
1055 | again: | ||
1056 | sym = find_symbol(name, &owner, &crc, | 1057 | sym = find_symbol(name, &owner, &crc, |
1057 | !(mod->taints & (1 << TAINT_PROPRIETARY_MODULE)), true); | 1058 | !(mod->taints & (1 << TAINT_PROPRIETARY_MODULE)), true); |
1058 | if (!sym) | 1059 | /* use_module can fail due to OOM, |
1059 | return NULL; | 1060 | or module initialization or unloading */ |
1060 | 1061 | if (sym) { | |
1061 | if (!check_version(sechdrs, versindex, name, mod, crc, owner)) | 1062 | if (!check_version(sechdrs, versindex, name, mod, crc, owner) |
1062 | return NULL; | 1063 | || !use_module(mod, owner)) |
1063 | 1064 | sym = NULL; | |
1064 | prepare_to_wait(&module_wq, &wait, TASK_INTERRUPTIBLE); | 1065 | } |
1065 | err = use_module(mod, owner); | 1066 | return sym; |
1066 | if (likely(!err) || err != -EBUSY || signal_pending(current)) { | ||
1067 | finish_wait(&module_wq, &wait); | ||
1068 | return err ? NULL : sym; | ||
1069 | } | ||
1070 | |||
1071 | /* Module is still loading. Drop lock and wait. */ | ||
1072 | mutex_unlock(&module_mutex); | ||
1073 | timeleft = schedule_timeout(timeleft); | ||
1074 | mutex_lock(&module_mutex); | ||
1075 | finish_wait(&module_wq, &wait); | ||
1076 | |||
1077 | /* Module might be gone entirely, or replaced. Re-lookup. */ | ||
1078 | if (timeleft) | ||
1079 | goto again; | ||
1080 | |||
1081 | printk(KERN_WARNING "%s: gave up waiting for init of module %s.\n", | ||
1082 | mod->name, owner->name); | ||
1083 | return NULL; | ||
1084 | } | 1067 | } |
1085 | 1068 | ||
1086 | /* | 1069 | /* |