objtool: Fix error handling inconsistencies in check()

[ Upstream commit b745962cb9 ]

Make sure all fatal errors are funneled through the 'out' label with a
negative ret.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Brendan Jackman <jackmanb@google.com>
Link: https://lore.kernel.org/r/0f49d6a27a080b4012e84e6df1e23097f44cc082.1741975349.git.jpoimboe@kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 4beb1e55f6b08aaa9376ed6926586e966bc4d319)
This commit is contained in:
Josh Poimboeuf 2025-03-14 12:29:00 -07:00 committed by Wentao Guan
parent 16a0dd1818
commit 70281bca59
1 changed files with 6 additions and 4 deletions

View File

@ -4793,8 +4793,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);
@ -4811,7 +4813,7 @@ int check(struct objtool_file *file)
if (opts.retpoline) {
ret = validate_retpoline(file);
if (ret < 0)
return ret;
goto out;
warnings += ret;
}
@ -4847,7 +4849,7 @@ int check(struct objtool_file *file)
*/
ret = validate_unrets(file);
if (ret < 0)
return ret;
goto out;
warnings += ret;
}
@ -4910,7 +4912,7 @@ int check(struct objtool_file *file)
if (opts.prefix) {
ret = add_prefix_symbols(file);
if (ret < 0)
return ret;
goto out;
warnings += ret;
}