aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/x86/kernel/alternative.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index 4b3378c71518..67dd7c371d28 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -233,6 +233,10 @@ static void noinline optimize_nops(const u8 * const instr, u8 *buf, size_t len)
if (insn_is_nop(&insn)) {
int nop = i;
+ /* Has the NOP already been optimized? */
+ if (i + insn.length == len)
+ return;
+
next = skip_nops(buf, next, len);
add_nop(buf + nop, next - nop);