From: WANG Cong Date: Tue, 6 May 2008 04:45:35 +0000 (+0800) Subject: [Patch] fs/binfmt_elf.c: fix a wrong free X-Git-Tag: v2.6.26-rc4~115^2~3 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=5f719558edf9c84bfbb1f7ad37e84c483282d09f;p=linux.git [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 Cc: Alexander Viro Reviewed-by: Pekka Enberg -- Signed-off-by: Al Viro --- 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 /* 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 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, un set_fs(fs); cleanup: - kfree(elf); free_note_info(&info); + kfree(elf); +out: return has_dumped; }