From 88a997871e9fbe6e358e0d0cb7e001cef388c32e Mon Sep 17 00:00:00 2001 From: Alexander Richards Date: Sat, 15 May 2021 19:45:23 +0200 Subject: [PATCH] AHCIController: Fix off-by-one mistake (#7144) Fixes off-by-one caused by reading the register directly without adding a 1 to it, because AHCI reports 1 less port than the actual number of ports supported. --- Kernel/Storage/AHCIController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel/Storage/AHCIController.cpp b/Kernel/Storage/AHCIController.cpp index 50413ca6c4..78a2aa3386 100644 --- a/Kernel/Storage/AHCIController.cpp +++ b/Kernel/Storage/AHCIController.cpp @@ -183,7 +183,7 @@ RefPtr AHCIController::device_by_port(u32 port_index) const RefPtr AHCIController::device(u32 index) const { NonnullRefPtrVector connected_devices; - for (size_t index = 0; index < (size_t)(hba().control_regs.cap & 0x1F); index++) { + for (size_t index = 0; index < capabilities().ports_count; index++) { auto checked_device = device_by_port(index); if (checked_device.is_null()) continue;