[PATCH 4/6] UML - Clean up after MADVISE_REMOVE

From: Jeff Dike
Date: Fri Apr 28 2006 - 13:00:19 EST


The MADVISE_REMOVE-checking code didn't clean up after itself.

Signed-off-by: Jeff Dike <jdike@xxxxxxxxxxx>

Index: linux-2.6.16/arch/um/os-Linux/process.c
===================================================================
--- linux-2.6.16.orig/arch/um/os-Linux/process.c 2006-04-27 20:51:58.000000000 -0400
+++ linux-2.6.16/arch/um/os-Linux/process.c 2006-04-28 12:20:55.000000000 -0400
@@ -206,29 +206,36 @@ int os_drop_memory(void *addr, int lengt
int can_drop_memory(void)
{
void *addr;
- int fd;
+ int fd, ok = 0;

printk("Checking host MADV_REMOVE support...");
fd = create_mem_file(UM_KERN_PAGE_SIZE);
if(fd < 0){
printk("Creating test memory file failed, err = %d\n", -fd);
- return 0;
+ goto out;
}

addr = mmap64(NULL, UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0);
if(addr == MAP_FAILED){
printk("Mapping test memory file failed, err = %d\n", -errno);
- return 0;
+ goto out_close;
}

if(madvise(addr, UM_KERN_PAGE_SIZE, MADV_REMOVE) != 0){
printk("MADV_REMOVE failed, err = %d\n", -errno);
- return 0;
+ goto out_unmap;
}

printk("OK\n");
- return 1;
+ ok = 1;
+
+out_unmap:
+ munmap(addr, UM_KERN_PAGE_SIZE);
+out_close:
+ close(fd);
+out:
+ return ok;
}

void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int))

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/