aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2012-11-27 16:19:17 +0000
committerMatt Fleming <matt.fleming@intel.com>2012-11-27 21:09:44 +0000
commit30ebd4f6bc83fa4832b658705d4020cb82dfdaea (patch)
treef8f5ccb359a899d83ea4847f9eb8bab8ee13962b
parent73bf7c135dfce1d0194de6677ed85495c64e300f (diff)
downloadsyslinux-30ebd4f6bc83fa4832b658705d4020cb82dfdaea.tar.gz
syslinux-30ebd4f6bc83fa4832b658705d4020cb82dfdaea.tar.xz
syslinux-30ebd4f6bc83fa4832b658705d4020cb82dfdaea.zip
module: Fix memory leak in spawn_load()
If for some reason we fail to load a module then we need to free the memory allocated to that module. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
-rw-r--r--com32/lib/sys/module/exec.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/com32/lib/sys/module/exec.c b/com32/lib/sys/module/exec.c
index 29d0a2fd..9ccab36e 100644
--- a/com32/lib/sys/module/exec.c
+++ b/com32/lib/sys/module/exec.c
@@ -194,8 +194,10 @@ int spawn_load(const char *name, int argc, char **argv)
return -1;
if (get_module_type(module) == EXEC_MODULE) {
- if (!argc || !argv || strcmp(argv[0], name))
- return -1;
+ if (!argc || !argv || strcmp(argv[0], name)) {
+ res = -1;
+ goto out;
+ }
}
if (!strcmp(cur_module->name, module->name)) {
@@ -218,10 +220,8 @@ int spawn_load(const char *name, int argc, char **argv)
}
res = module_load(module);
- if (res != 0) {
- _module_unload(module);
- return res;
- }
+ if (res != 0)
+ goto out;
type = get_module_type(module);
prev_module = cur_module;
@@ -259,14 +259,16 @@ int spawn_load(const char *name, int argc, char **argv)
cur_module = prev_module;
res = module_unload(module);
- if (res != 0) {
- return res;
- }
+ if (res != 0)
+ goto out;
return ((unsigned int)ret_val & 0xFF);
}
- return 0;
+out:
+ if (res)
+ _module_unload(module);
+ return res;
}
void exec_term(void)