Blob Blame History Raw
From: Josh Poimboeuf <jpoimboe@redhat.com>
Date: Wed, 1 Apr 2020 13:23:29 -0500
Subject: objtool: Make BP scratch register warning more robust
Git-commit: b296695298d8632d8b703ac25fe70be34a07c0d9
Patch-mainline: v5.7-rc2
References: bsc#1169514

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: c705cecc8431 ("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

Acked-by: Miroslav Benes <mbenes@suse.cz>
---
 tools/objtool/check.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1923,8 +1923,8 @@ static int validate_branch(struct objtoo
 			}
 
 			if (state.bp_scratch) {
-				WARN("%s uses BP as a scratch register",
-				     func->name);
+				WARN_FUNC("BP used as a scratch register",
+					  sec, insn->offset);
 				return 1;
 			}