[PATCH 02/13] objtool: Fix error handling inconsistencies in check()

Josh Poimboeuf posted 13 patches 9 months, 1 week ago
[PATCH 02/13] objtool: Fix error handling inconsistencies in check()
Posted by Josh Poimboeuf 9 months, 1 week ago
Make sure all fatal errors are funneled through the 'out' label with a
negative ret.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 tools/objtool/check.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 3a3a1a905199..2b5249af7b0f 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -4586,8 +4586,10 @@ int check(struct objtool_file *file)
 	init_cfi_state(&force_undefined_cfi);
 	force_undefined_cfi.force_undefined = true;
 
-	if (!cfi_hash_alloc(1UL << (file->elf->symbol_bits - 3)))
+	if (!cfi_hash_alloc(1UL << (file->elf->symbol_bits - 3))) {
+		ret = -1;
 		goto out;
+	}
 
 	cfi_hash_add(&init_cfi);
 	cfi_hash_add(&func_cfi);
@@ -4604,7 +4606,7 @@ int check(struct objtool_file *file)
 	if (opts.retpoline) {
 		ret = validate_retpoline(file);
 		if (ret < 0)
-			return ret;
+			goto out;
 		warnings += ret;
 	}
 
@@ -4640,7 +4642,7 @@ int check(struct objtool_file *file)
 		 */
 		ret = validate_unrets(file);
 		if (ret < 0)
-			return ret;
+			goto out;
 		warnings += ret;
 	}
 
@@ -4703,7 +4705,7 @@ int check(struct objtool_file *file)
 	if (opts.prefix) {
 		ret = add_prefix_symbols(file);
 		if (ret < 0)
-			return ret;
+			goto out;
 		warnings += ret;
 	}
 
-- 
2.48.1
Re: [PATCH 02/13] objtool: Fix error handling inconsistencies in check()
Posted by Miroslav Benes 9 months ago
On Fri, 14 Mar 2025, Josh Poimboeuf wrote:

> Make sure all fatal errors are funneled through the 'out' label with a
> negative ret.
> 
> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>

Reviewed-by: Miroslav Benes <mbenes@suse.cz>

M
Re: [PATCH 02/13] objtool: Fix error handling inconsistencies in check()
Posted by Brendan Jackman 9 months ago
On Fri, Mar 14, 2025 at 12:29:00PM -0700, Josh Poimboeuf wrote:
> Make sure all fatal errors are funneled through the 'out' label with a
> negative ret.
> 
> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>

Reviewed-by: Brendan Jackman <jackmanb@google.com>