1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:37:35 +00:00

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.
This commit is contained in:
Alexander Richards 2021-05-15 19:45:23 +02:00 committed by GitHub
parent 0fb96e6cbf
commit 88a997871e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -183,7 +183,7 @@ RefPtr<StorageDevice> AHCIController::device_by_port(u32 port_index) const
RefPtr<StorageDevice> AHCIController::device(u32 index) const
{
NonnullRefPtrVector<StorageDevice> 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;