1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:38:10 +00:00

Kernel/PCI: Break early of controller iteration over devices in OOM case

This is mainly useful when adding an HostController but due to OOM
condition, we abort temporary Vector insertion of a DeviceIdentifier
and then exit the iteration loop to report back the error if occured.
This commit is contained in:
Liav A 2022-02-04 22:11:50 +02:00 committed by Andreas Kling
parent 3fb289e27d
commit 428d4ae337
5 changed files with 18 additions and 13 deletions

View file

@ -5,6 +5,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/IterationDecision.h>
#include <AK/Singleton.h>
#include <AK/StringView.h>
#include <AK/UUID.h>
@ -53,7 +54,7 @@ UNMAP_AFTER_INIT void StorageManagement::enumerate_pci_controllers(bool force_pi
using SubclassID = PCI::MassStorage::SubclassID;
if (!kernel_command_line().disable_physical_storage()) {
MUST(PCI::enumerate([&](PCI::DeviceIdentifier const& device_identifier) {
MUST(PCI::enumerate([&](PCI::DeviceIdentifier const& device_identifier) -> void {
if (device_identifier.class_code().value() != to_underlying(PCI::ClassID::MassStorage)) {
return;
}