The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v4] x86/kaslr: Remove redundant if check in slots_fetch_random()
@ 2026-08-04 16:35 Thorsten Blum
  0 siblings, 0 replies; only message in thread
From: Thorsten Blum @ 2026-08-04 16:35 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Thorsten Blum
  Cc: linux-kernel

The loop in slots_fetch_random() either returns the slot address or
exits with i == slot_area_index, making the if check redundant. Drop it.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
Changes in v4:
- Drop the change in choose_random_location()
- Reword subject and patch description
- v3: https://lore.kernel.org/r/20260802093531.7165-2-thorsten.blum@linux.dev/

Changes in v3:
- Name commit 8391c73c96f2 that added the check (Boris)
- Keep the comment (Boris)
- v2: https://lore.kernel.org/r/20260731073933.685882-3-thorsten.blum@linux.dev/

Changes in v2:
- Explain why the check in choose_random_location() is redundant (Boris)
- Reword subject
- v1: https://lore.kernel.org/r/20260714205752.133163-2-thorsten.blum@linux.dev/
---
 arch/x86/boot/compressed/kaslr.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
index 81e21c76cbb8..34ee7700ab85 100644
--- a/arch/x86/boot/compressed/kaslr.c
+++ b/arch/x86/boot/compressed/kaslr.c
@@ -541,8 +541,7 @@ static u64 slots_fetch_random(void)
 		return slot_areas[i].addr + ((u64)slot * CONFIG_PHYSICAL_ALIGN);
 	}
 
-	if (i == slot_area_index)
-		debug_putstr("slots_fetch_random() failed!?\n");
+	debug_putstr("slots_fetch_random() failed!?\n");
 	return 0;
 }
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-08-04 16:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-04 16:35 [PATCH v4] x86/kaslr: Remove redundant if check in slots_fetch_random() Thorsten Blum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox