]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
objtool: Fix segfault in ignore_unreachable_insn()
authorJosh Poimboeuf <jpoimboe@kernel.org>
Fri, 28 Mar 2025 05:04:21 +0000 (22:04 -0700)
committerIngo Molnar <mingo@kernel.org>
Fri, 28 Mar 2025 13:47:02 +0000 (14:47 +0100)
Check 'prev_insn' before dereferencing it.

Fixes: bd841d6154f5 ("objtool: Fix CONFIG_UBSAN_TRAP unreachable warnings")
Reported-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/5df4ff89c9e4b9e788b77b0531234ffa7ba03e9e.1743136205.git.jpoimboe@kernel.org
Closes: https://lore.kernel.org/d86b4cc6-0b97-4095-8793-a7384410b8ab@app.fastmail.com
Closes: https://lore.kernel.org/Z-V_rruKY0-36pqA@gmail.com
tools/objtool/check.c

index 3bf29923d5c0234d371b42500d17654da3d3ec26..29de1709ea004dbf486b06c5a7bae4c7401b28c3 100644 (file)
@@ -4037,7 +4037,7 @@ static bool ignore_unreachable_insn(struct objtool_file *file, struct instructio
         * It may also insert a UD2 after calling a __noreturn function.
         */
        prev_insn = prev_insn_same_sec(file, insn);
-       if (prev_insn->dead_end &&
+       if (prev_insn && prev_insn->dead_end &&
            (insn->type == INSN_BUG ||
             (insn->type == INSN_JUMP_UNCONDITIONAL &&
              insn->jump_dest && insn->jump_dest->type == INSN_BUG)))