diff options
author | WANG Cong <xiyou.wangcong@gmail.com> | 2008-05-06 00:45:35 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2008-05-16 17:22:58 -0400 |
commit | 5f719558edf9c84bfbb1f7ad37e84c483282d09f (patch) | |
tree | acbd9ec7343ad6d7933015c40b0acf378a2d2418 /fs | |
parent | eceea0b3df05ed262ae32e0c6340cc7a3626632d (diff) |
[Patch] fs/binfmt_elf.c: fix a wrong free
In kmalloc failing path, we shouldn't free pointers in 'info',
because the struct 'info' is uninitilized when kmalloc is called.
And when kmalloc returns NULL, it's needless to kfree it.
Signed-off-by: WANG Cong <wangcong@zeuux.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Reviewed-by: Pekka Enberg <penberg@cs.helsinki.fi>
--
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/binfmt_elf.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index b25707fee2cc..bd08332079cf 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -1900,7 +1900,7 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, un | |||
1900 | /* alloc memory for large data structures: too large to be on stack */ | 1900 | /* alloc memory for large data structures: too large to be on stack */ |
1901 | elf = kmalloc(sizeof(*elf), GFP_KERNEL); | 1901 | elf = kmalloc(sizeof(*elf), GFP_KERNEL); |
1902 | if (!elf) | 1902 | if (!elf) |
1903 | goto cleanup; | 1903 | goto out; |
1904 | 1904 | ||
1905 | segs = current->mm->map_count; | 1905 | segs = current->mm->map_count; |
1906 | #ifdef ELF_CORE_EXTRA_PHDRS | 1906 | #ifdef ELF_CORE_EXTRA_PHDRS |
@@ -2034,8 +2034,9 @@ end_coredump: | |||
2034 | set_fs(fs); | 2034 | set_fs(fs); |
2035 | 2035 | ||
2036 | cleanup: | 2036 | cleanup: |
2037 | kfree(elf); | ||
2038 | free_note_info(&info); | 2037 | free_note_info(&info); |
2038 | kfree(elf); | ||
2039 | out: | ||
2039 | return has_dumped; | 2040 | return has_dumped; |
2040 | } | 2041 | } |
2041 | 2042 | ||