[Patch 3/9] fs/compat.c: fix resource leaks and wrong goto's
From: WANG Cong
Date: Thu May 08 2008 - 09:56:28 EST
Use free_arg_pages() to free the pages allocated by copy_strings_kernel()
on failure. And fix some related wrong goto pathes.
Signed-off-by: WANG Cong <wangcong@xxxxxxxxx>
Cc: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx>
---
diff --git a/fs/compat.c b/fs/compat.c
index 332a869..7e836ff 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -1381,15 +1381,15 @@ int compat_do_execve(char * filename,
retval = security_bprm_alloc(bprm);
if (retval)
- goto out;
+ goto out_mm;
retval = prepare_binprm(bprm);
if (retval < 0)
- goto out;
+ goto out_sec;
retval = copy_strings_kernel(1, &bprm->filename, bprm);
if (retval < 0)
- goto out;
+ goto out_sec;
bprm->exec = bprm->p;
retval = compat_copy_strings(bprm->envc, envp, bprm);
@@ -1403,6 +1403,7 @@ int compat_do_execve(char * filename,
retval = search_binary_handler(bprm, regs);
if (retval >= 0) {
/* execve success */
+ free_arg_pages(bprm);
security_bprm_free(bprm);
acct_update_integrals(current);
kfree(bprm);
@@ -1410,6 +1411,9 @@ int compat_do_execve(char * filename,
}
out:
+ free_arg_pages(bprm);
+
+out_sec:
if (bprm->security)
security_bprm_free(bprm);
--
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/