Skip to contentSkip to conversation

x86/kaslr: Remove redundant if check in slots_fetch_random()

PATCH New Thorsten Blum 1 participant 1 message Aug 4 x86

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 x86/kaslr: Remove redundant if check in slots_fetch_random()

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.

---
Changes in v4:
- Drop the change in choose_random_location()
- Reword subject and patch description
- v3: https://lore.kernel.org/r/[email protected]/

Changes in v3:
- Name commit 8391c73c96f2 that added the check (Boris)
- Keep the comment (Boris)
- v2: https://lore.kernel.org/r/[email protected]/

Changes in v2:
- Explain why the check in choose_random_location() is redundant (Boris)
- Reword subject
- v1: https://lore.kernel.org/r/[email protected]/

---
 arch/x86/boot/compressed/kaslr.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/boot/compressed/kaslr.c +1 -2
index 81e21c76cbb8..34ee7700ab85 100644
@@ -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;
 }