[PATCH] memory leak with execve failure

From: IWAMOTO Toshihiro
Date: Mon Dec 22 2003 - 04:25:33 EST


I found linux-2.6.0-test11 leaks memory when execve fails.
I've also checked the bitkeeper tree and the problem seems to be
unchanged.

The attached patch is a partial backout of bitkeeper rev. 1.87 of
fs/exec.c. I guess the original change was a simple mistake.
(free_arg_pages() is a NOP when CONFIG_MMU is defined).

--- linux-2.6.0-test11/fs/exec.c Thu Nov 27 05:43:36 2003
+++ linux-2.6.0-test11-new/fs/exec.c Mon Dec 22 17:50:24 2003
@@ -1070,6 +1070,7 @@ int do_execve(char * filename,
struct linux_binprm bprm;
struct file *file;
int retval;
+ int i;

sched_balance_exec();

@@ -1138,7 +1139,11 @@ int do_execve(char * filename,

out:
/* Something went wrong, return the inode and free the argument pages*/
- free_arg_pages(&bprm);
+ for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
+ struct page * page = bprm.page[i];
+ if (page)
+ __free_page(page);
+ }

if (bprm.security)
security_bprm_free(&bprm);


--
IWAMOTO Toshihiro

-
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/