From: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>

This patch fixes a memory leak that happens when a core file hits the
process's resource limit.


---

 25-akpm/fs/binfmt_elf.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletion(-)

diff -puN fs/binfmt_elf.c~coredump-memleak-fix fs/binfmt_elf.c
--- 25/fs/binfmt_elf.c~coredump-memleak-fix	Mon Feb  2 14:11:45 2004
+++ 25-akpm/fs/binfmt_elf.c	Mon Feb  2 14:11:45 2004
@@ -1448,7 +1448,13 @@ static int elf_core_dump(long signr, str
 					void *kaddr;
 					flush_cache_page(vma, addr);
 					kaddr = kmap(page);
-					DUMP_WRITE(kaddr, PAGE_SIZE);
+					if ((size += PAGE_SIZE) > limit ||
+					    !dump_write(file, kaddr,
+					    PAGE_SIZE)) {
+						kunmap(page);
+						page_cache_release(page);
+						goto end_coredump;
+					}
 					kunmap(page);
 				}
 				page_cache_release(page);

_