]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
x86/alternative: Drop not needed test after call of alt_replace_call()
authorJuergen Gross <jgross@suse.com>
Mon, 29 Sep 2025 11:29:45 +0000 (13:29 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Tue, 14 Oct 2025 08:38:11 +0000 (10:38 +0200)
alt_replace_call() will never return a negative value, so testing the
return value to be less than zero can be dropped.

This makes it possible to switch the return type of alt_replace_call()
and the type of insn_buff_sz to unsigned int.

Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
arch/x86/kernel/alternative.c

index 8ee5ff547357a5b6166363eb1aaf3d13cf8f6b09..4f3ea50e41e82ba93105a7c8c236f673f71e991e 100644 (file)
@@ -559,7 +559,7 @@ EXPORT_SYMBOL(BUG_func);
  * Rewrite the "call BUG_func" replacement to point to the target of the
  * indirect pv_ops call "call *disp(%ip)".
  */
-static int alt_replace_call(u8 *instr, u8 *insn_buff, struct alt_instr *a)
+static unsigned int alt_replace_call(u8 *instr, u8 *insn_buff, struct alt_instr *a)
 {
        void *target, *bug = &BUG_func;
        s32 disp;
@@ -643,7 +643,7 @@ void __init_or_module noinline apply_alternatives(struct alt_instr *start,
         * order.
         */
        for (a = start; a < end; a++) {
-               int insn_buff_sz = 0;
+               unsigned int insn_buff_sz = 0;
 
                /*
                 * In case of nested ALTERNATIVE()s the outer alternative might
@@ -683,11 +683,8 @@ void __init_or_module noinline apply_alternatives(struct alt_instr *start,
                memcpy(insn_buff, replacement, a->replacementlen);
                insn_buff_sz = a->replacementlen;
 
-               if (a->flags & ALT_FLAG_DIRECT_CALL) {
+               if (a->flags & ALT_FLAG_DIRECT_CALL)
                        insn_buff_sz = alt_replace_call(instr, insn_buff, a);
-                       if (insn_buff_sz < 0)
-                               continue;
-               }
 
                for (; insn_buff_sz < a->instrlen; insn_buff_sz++)
                        insn_buff[insn_buff_sz] = 0x90;