diff options
author | Jeff Dike <jdike@addtoit.com> | 2006-05-01 15:15:58 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-05-01 21:17:44 -0400 |
commit | e3104f50d89b1fffe1fd973e32248a5c7f1bb41e (patch) | |
tree | fc1b191345acb4eb30455bd3efddb73a4c463d68 /arch | |
parent | 191ef966ac164a1ce3e06290ca52296744a4aee2 (diff) |
[PATCH] uml: clean up after MADVISE_REMOVE
The MADVISE_REMOVE-checking code didn't clean up after itself.
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/um/os-Linux/process.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/arch/um/os-Linux/process.c b/arch/um/os-Linux/process.c index 3505f44f8a25..233be2f4f8cb 100644 --- a/arch/um/os-Linux/process.c +++ b/arch/um/os-Linux/process.c | |||
@@ -206,29 +206,36 @@ int os_drop_memory(void *addr, int length) | |||
206 | int can_drop_memory(void) | 206 | int can_drop_memory(void) |
207 | { | 207 | { |
208 | void *addr; | 208 | void *addr; |
209 | int fd; | 209 | int fd, ok = 0; |
210 | 210 | ||
211 | printk("Checking host MADV_REMOVE support..."); | 211 | printk("Checking host MADV_REMOVE support..."); |
212 | fd = create_mem_file(UM_KERN_PAGE_SIZE); | 212 | fd = create_mem_file(UM_KERN_PAGE_SIZE); |
213 | if(fd < 0){ | 213 | if(fd < 0){ |
214 | printk("Creating test memory file failed, err = %d\n", -fd); | 214 | printk("Creating test memory file failed, err = %d\n", -fd); |
215 | return 0; | 215 | goto out; |
216 | } | 216 | } |
217 | 217 | ||
218 | addr = mmap64(NULL, UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE, | 218 | addr = mmap64(NULL, UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE, |
219 | MAP_SHARED, fd, 0); | 219 | MAP_SHARED, fd, 0); |
220 | if(addr == MAP_FAILED){ | 220 | if(addr == MAP_FAILED){ |
221 | printk("Mapping test memory file failed, err = %d\n", -errno); | 221 | printk("Mapping test memory file failed, err = %d\n", -errno); |
222 | return 0; | 222 | goto out_close; |
223 | } | 223 | } |
224 | 224 | ||
225 | if(madvise(addr, UM_KERN_PAGE_SIZE, MADV_REMOVE) != 0){ | 225 | if(madvise(addr, UM_KERN_PAGE_SIZE, MADV_REMOVE) != 0){ |
226 | printk("MADV_REMOVE failed, err = %d\n", -errno); | 226 | printk("MADV_REMOVE failed, err = %d\n", -errno); |
227 | return 0; | 227 | goto out_unmap; |
228 | } | 228 | } |
229 | 229 | ||
230 | printk("OK\n"); | 230 | printk("OK\n"); |
231 | return 1; | 231 | ok = 1; |
232 | |||
233 | out_unmap: | ||
234 | munmap(addr, UM_KERN_PAGE_SIZE); | ||
235 | out_close: | ||
236 | close(fd); | ||
237 | out: | ||
238 | return ok; | ||
232 | } | 239 | } |
233 | 240 | ||
234 | void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int)) | 241 | void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int)) |