* [Resend Patch] fs/binfmt_elf.c: fix a wrong free
@ 2008-05-06 4:45 WANG Cong
0 siblings, 0 replies; only message in thread
From: WANG Cong @ 2008-05-06 4:45 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Pekka Enberg, Alexander Viro
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>
--
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index f6d5a9d..357b503 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
/* alloc memory for large data structures: too large to be on stack */
elf = kmalloc(sizeof(*elf), GFP_KERNEL);
if (!elf)
- goto cleanup;
+ goto out;
segs = current->mm->map_count;
#ifdef ELF_CORE_EXTRA_PHDRS
@@ -2034,8 +2034,9 @@ end_coredump:
set_fs(fs);
cleanup:
- kfree(elf);
free_note_info(&info);
+ kfree(elf);
+out:
return has_dumped;
}
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2008-05-06 4:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-06 4:45 [Resend Patch] fs/binfmt_elf.c: fix a wrong free WANG Cong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox