Skip to content

Commit

Permalink
[Patch] fs/binfmt_elf.c: fix a wrong free
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Alexander Viro <[email protected]>
Reviewed-by: Pekka Enberg <[email protected]>

--
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
congwang authored and Al Viro committed May 16, 2008
1 parent eceea0b commit 5f71955
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fs/binfmt_elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 5f71955

Please sign in to comment.