提交 5f719558 编写于 作者: W WANG Cong 提交者: Al Viro

[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: NWANG Cong <wangcong@zeuux.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Reviewed-by: NPekka Enberg <penberg@cs.helsinki.fi>

--
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 eceea0b3
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册