objtool: check: Fix NULL pointer dereference
PATCH 1/1 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")
--- tools/objtool/check.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/objtool/check.c +1 -1
@@ -2025,7 +2025,7 @@ static int validate_return(struct symbol *func, struct instruction *insn, structreturn 1 ; } -if (state->bp_scratch) { +if (func && state->bp_scratch) {WARN ("%s uses BP as a scratch register" , func->name);return 1 ;
Signature · 1 line
2.26.0
Quoted 19 lines · Gustavo A. R. Silva
In case func is null, there is a null pointer dereference at 2029:
2029 WARN("%s uses BP as a scratch register",
2030func->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 <[email protected]>--- tools/objtool/check.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/objtool/check.c +0
-0
tools/objtool/check.c static int validate_return(struct symbol *func, struct instruction *insn, struct · line 2031
Quoted 8 lines
tools/objtool/check.c +1
-1@@ -2025,7 +2025,7 @@ static int validate_return(struct symbol *func, struct instruction *insn, structreturn 1 ; } -if (state->bp_scratch) { +if (func && state->bp_scratch) {WARN ("%s uses BP as a scratch register" , func->name);return 1 ;
We should still do the warning even if there's no func. I'll make a slightly different patch which unconditionally uses WARN_FUNC().
I'll give you Reported-by credit and keep the coverity tag. Thanks!
Signature · 1 line
Josh
Quoted 23 lines · Josh Poimboeuf
Quoted 22 lines · Gustavo A. R. Silva
In case func is null, there is a null pointer dereference at 2029:
2029 WARN("%s uses BP as a scratch register",
2030func->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 <[email protected]>--- tools/objtool/check.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/objtool/check.c +0
-0@@ -2025,7 +2025,7 @@ static int validate_return(struct symbol *func, struct instruction *insn, structreturn 1 ; }
Quoted 9 lines
tools/objtool/check.c static int validate_return(struct symbol *func, struct instruction *insn, struct · line 2031
Quoted 5 lines
tools/objtool/check.c +1
-1-if (state->bp_scratch) { +if (func && state->bp_scratch) {WARN ("%s uses BP as a scratch register" , func->name);return 1 ;We should still do the warning even if there's no func. I'll make a slightly different patch which unconditionally uses
WARN_FUNC().
Awesome. :)
Quoted 2 lines
I'll give you Reported-by credit and keep the coverity tag. Thanks!
Great.
Thanks
--
Gustavo