lkml.org 
[lkml]   [2020]   [Mar]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] objtool: check: Fix NULL pointer dereference
In case func is null, there is a null pointer dereference at 2029:

2029 WARN("%s uses BP as a scratch register",
2030 func->name);

Fix this by null-checking func.

Addresses-Coverity-ID: 1492002 ("Dereference after null check")
Fixes: c705cecc8431 ("objtool: Track original function across branches")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
tools/objtool/check.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index e3bb76358148..182cc48fa892 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2025,7 +2025,7 @@ static int validate_return(struct symbol *func, struct instruction *insn, struct
return 1;
}

- if (state->bp_scratch) {
+ if (func && state->bp_scratch) {
WARN("%s uses BP as a scratch register",
func->name);
return 1;
--
2.26.0
\
 
 \ /
  Last update: 2020-03-31 02:17    [W:0.036 / U:4.744 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site