Skip to content

Commit

Permalink
objtool: Make BP scratch register warning more robust
Browse files Browse the repository at this point in the history
If func is NULL, a seg fault can result.

This is a theoretical issue which was found by Coverity, ID: 1492002
("Dereference after null check").

Fixes: c705cec ("objtool: Track original function across branches")
Reported-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/afc628693a37acd287e843bcc5c0430263d93c74.1585761021.git.jpoimboe@redhat.com
  • Loading branch information
Josh Poimboeuf authored and Borislav Petkov committed Apr 14, 2020
1 parent b401efc commit b296695
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/objtool/check.c
Original file line number Diff line number Diff line change
Expand Up @@ -2005,8 +2005,8 @@ static int validate_return(struct symbol *func, struct instruction *insn, struct
}

if (state->bp_scratch) {
WARN("%s uses BP as a scratch register",
func->name);
WARN_FUNC("BP used as a scratch register",
insn->sec, insn->offset);
return 1;
}

Expand Down

0 comments on commit b296695

Please sign in to comment.