aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2012-11-29 11:35:28 +0000
committerMatt Fleming <matt.fleming@intel.com>2012-11-29 13:30:16 +0000
commit8f1c64acf9c60d184fef37f373737895468c0771 (patch)
tree34867eb23ee4d934bc1fc8e087065bae0d40f2e0
parent0174945b6b604425e8f576c0af0908ce00cdc493 (diff)
downloadsyslinux-8f1c64acf9c60d184fef37f373737895468c0771.tar.gz
syslinux-8f1c64acf9c60d184fef37f373737895468c0771.tar.xz
syslinux-8f1c64acf9c60d184fef37f373737895468c0771.zip
module: Stop silently failing to load dependency modulessyslinux-5.00-pre12
We should be checking the return value of spawn_load() when loading a module's dependencies and printing some kind of an error message if they fail to load (for instance if the file is missing) and returning an error to the caller. Track the most recently loaded module in 'head' before we begin loading dependencies. That way we can unload any dependencies in the error path that were successfully loaded. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
-rw-r--r--com32/lib/sys/module/elf_module.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/com32/lib/sys/module/elf_module.c b/com32/lib/sys/module/elf_module.c
index c92fe266..8a8ed20e 100644
--- a/com32/lib/sys/module/elf_module.c
+++ b/com32/lib/sys/module/elf_module.c
@@ -492,6 +492,7 @@ int module_load(struct elf_module *module) {
Elf32_Sym *main_sym;
Elf32_Ehdr elf_hdr;
module_ctor_t *ctor;
+ struct elf_module *head = NULL;
// Do not allow duplicate modules
if (module_find(module->name) != NULL) {
@@ -525,6 +526,8 @@ int module_load(struct elf_module *module) {
CHECKED(res, prepare_dynlinking(module), error);
//printf("check... 4\n");
+ head = list_entry(&modules_head, typeof(*head), list);
+
/* Find modules we need to load as dependencies */
if (module->str_table) {
int i;
@@ -550,7 +553,11 @@ int module_load(struct elf_module *module) {
p = dep;
argv[0] = p;
- spawn_load(p, 1, argv);
+ res = spawn_load(p, 1, argv);
+ if (res < 0) {
+ printf("Failed to load %s\n", p);
+ goto error;
+ }
}
}
@@ -595,6 +602,9 @@ int module_load(struct elf_module *module) {
return 0;
error:
+ if (head)
+ unload_modules_since(head->name);
+
// Remove the module from the module list (if applicable)
list_del_init(&module->list);