Skip to content

Commit

Permalink
AHCIController: Fix off-by-one mistake (SerenityOS#7144)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ElectrodeYT committed May 15, 2021
1 parent 0fb96e6 commit 88a9978
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Kernel/Storage/AHCIController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 88a9978

Please sign in to comment.