diff options
author | Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> | 2006-10-20 02:28:24 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-20 13:26:36 -0400 |
commit | d9d645f06a8f50659bbae2be64ed8367ba068fc0 (patch) | |
tree | a514ffe62493538e0e5725685380b961e6ca4483 /arch/um/os-Linux | |
parent | b2670eacfb013169b8bf151a5078a9ef8ef86466 (diff) |
[PATCH] uml: cleanup run_helper() API to fix a leak
Freeing the stack is left uselessly to the caller of run_helper in some cases
- this is taken from run_helper_thread, but here it is useless, so no caller
needs it and the only place where this happens has a potential leak - in case
of error neither run_helper() nor xterm_open() call free_stack(). At this
point passing a pointer is not needed - the stack pointer should be passed
directly, but this change is not done here.
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Cc: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/os-Linux')
-rw-r--r-- | arch/um/os-Linux/helper.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/arch/um/os-Linux/helper.c b/arch/um/os-Linux/helper.c index 8a78bf03b468..d13299cfa318 100644 --- a/arch/um/os-Linux/helper.c +++ b/arch/um/os-Linux/helper.c | |||
@@ -50,7 +50,8 @@ static int helper_child(void *arg) | |||
50 | } | 50 | } |
51 | 51 | ||
52 | /* Returns either the pid of the child process we run or -E* on failure. | 52 | /* Returns either the pid of the child process we run or -E* on failure. |
53 | * XXX The alloc_stack here breaks if this is called in the tracing thread */ | 53 | * XXX The alloc_stack here breaks if this is called in the tracing thread, so |
54 | * we need to receive a preallocated stack (a local buffer is ok). */ | ||
54 | int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv, | 55 | int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv, |
55 | unsigned long *stack_out) | 56 | unsigned long *stack_out) |
56 | { | 57 | { |
@@ -113,10 +114,8 @@ out_close: | |||
113 | close(fds[1]); | 114 | close(fds[1]); |
114 | close(fds[0]); | 115 | close(fds[0]); |
115 | out_free: | 116 | out_free: |
116 | if (stack_out == NULL) | 117 | if ((stack_out == NULL) || (*stack_out == 0)) |
117 | free_stack(stack, 0); | 118 | free_stack(stack, 0); |
118 | else | ||
119 | *stack_out = stack; | ||
120 | return ret; | 119 | return ret; |
121 | } | 120 | } |
122 | 121 | ||