Skip to content

Commit 79cd7b0

Browse files
sm00thgregkh
authored andcommitted
objtool: Fix double-free in .cold detection error path
[ Upstream commit 0b9301f ] If read_symbols() fails during second list traversal (the one dealing with ".cold" subfunctions) it frees the symbol, but never deletes it from the list/hash_table resulting in symbol being freed again in elf_close(). Fix it by just returning an error, leaving cleanup to elf_close(). Signed-off-by: Artem Savkov <asavkov@redhat.com> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Fixes: 1381043 ("objtool: Support GCC 8's cold subfunctions") Link: http://lkml.kernel.org/r/beac5a9b7da9e8be90223459dcbe07766ae437dd.1542736240.git.jpoimboe@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent a8657e6 commit 79cd7b0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎tools/objtool/elf.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ static int read_symbols(struct elf *elf)
312312
if (!pfunc) {
313313
WARN("%s(): can't find parent function",
314314
sym->name);
315-
goto err;
315+
return -1;
316316
}
317317

318318
sym->pfunc = pfunc;

0 commit comments

Comments
 (0)