diff --git a/Kernel/Memory/ScatterGatherList.cpp b/Kernel/Memory/ScatterGatherList.cpp index 1eb9b6e53b..f49237c2d9 100644 --- a/Kernel/Memory/ScatterGatherList.cpp +++ b/Kernel/Memory/ScatterGatherList.cpp @@ -8,14 +8,10 @@ namespace Kernel::Memory { -LockRefPtr ScatterGatherList::try_create(AsyncBlockDeviceRequest& request, Span> allocated_pages, size_t device_block_size) +ErrorOr> ScatterGatherList::try_create(AsyncBlockDeviceRequest& request, Span> allocated_pages, size_t device_block_size) { - auto maybe_vm_object = AnonymousVMObject::try_create_with_physical_pages(allocated_pages); - if (maybe_vm_object.is_error()) { - // FIXME: Would be nice to be able to return a ErrorOr here. - return {}; - } - return adopt_lock_ref_if_nonnull(new (nothrow) ScatterGatherList(maybe_vm_object.release_value(), request, device_block_size)); + auto vm_object = TRY(AnonymousVMObject::try_create_with_physical_pages(allocated_pages)); + return adopt_lock_ref_if_nonnull(new (nothrow) ScatterGatherList(vm_object, request, device_block_size)); } ScatterGatherList::ScatterGatherList(NonnullLockRefPtr vm_object, AsyncBlockDeviceRequest& request, size_t device_block_size) diff --git a/Kernel/Memory/ScatterGatherList.h b/Kernel/Memory/ScatterGatherList.h index bcd2e496ce..d6920f025b 100644 --- a/Kernel/Memory/ScatterGatherList.h +++ b/Kernel/Memory/ScatterGatherList.h @@ -19,7 +19,7 @@ namespace Kernel::Memory { class ScatterGatherList final : public AtomicRefCounted { public: - static LockRefPtr try_create(AsyncBlockDeviceRequest&, Span> allocated_pages, size_t device_block_size); + static ErrorOr> try_create(AsyncBlockDeviceRequest&, Span> allocated_pages, size_t device_block_size); VMObject const& vmobject() const { return m_vm_object; } VirtualAddress dma_region() const { return m_dma_region->vaddr(); } size_t scatters_count() const { return m_vm_object->physical_pages().size(); } diff --git a/Kernel/Storage/ATA/AHCI/Port.cpp b/Kernel/Storage/ATA/AHCI/Port.cpp index 2760dff2db..c6b55c9cd3 100644 --- a/Kernel/Storage/ATA/AHCI/Port.cpp +++ b/Kernel/Storage/ATA/AHCI/Port.cpp @@ -429,7 +429,7 @@ Optional AHCIPort::prepare_and_set_scatter_li allocated_dma_regions.append(m_dma_buffers.at(index)); } - m_current_scatter_list = Memory::ScatterGatherList::try_create(request, allocated_dma_regions.span(), m_connected_device->block_size()); + m_current_scatter_list = Memory::ScatterGatherList::try_create(request, allocated_dma_regions.span(), m_connected_device->block_size()).release_value_but_fixme_should_propagate_errors(); if (!m_current_scatter_list) return AsyncDeviceRequest::Failure; if (request.request_type() == AsyncBlockDeviceRequest::Write) {