]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[Patch] fs/binfmt_elf.c: fix a wrong free
authorWANG Cong <xiyou.wangcong@gmail.com>
Tue, 6 May 2008 04:45:35 +0000 (12:45 +0800)
committerAl Viro <viro@zeniv.linux.org.uk>
Fri, 16 May 2008 21:22:58 +0000 (17:22 -0400)
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>
fs/binfmt_elf.c

index b25707fee2ccad4598146224a5b5c5abcf3c2f99..bd08332079cf89b460d5e62314760af704c7b8f8 100644 (file)
@@ -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;
 }