提交 b7037983 编写于 作者: K Kamalesh Babulal 提交者: Ingo Molnar

objtool: Fix memory leak in decode_instructions()

When an error occurs before adding an allocated insn to the list, free
it before returning.
Signed-off-by: NKamalesh Babulal <kamalesh@linux.vnet.ibm.com>
Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/336da800bf6070eae11f4e0a3b9ca64c27658114.1508430423.git.jpoimboe@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
上级 ce43f4fd
......@@ -267,12 +267,13 @@ static int decode_instructions(struct objtool_file *file)
&insn->immediate,
&insn->stack_op);
if (ret)
return ret;
goto err;
if (!insn->type || insn->type > INSN_LAST) {
WARN_FUNC("invalid instruction type %d",
insn->sec, insn->offset, insn->type);
return -1;
ret = -1;
goto err;
}
hash_add(file->insn_hash, &insn->hash, insn->offset);
......@@ -296,6 +297,10 @@ static int decode_instructions(struct objtool_file *file)
}
return 0;
err:
free(insn);
return ret;
}
/*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册