mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
Kernel: Make Inode::set_shared_vmobject() OOM-fallible
Allocating a WeakPtr can fail, so this let's us properly propagate said failure.
This commit is contained in:
parent
c620f18d8c
commit
e37e4a7980
Notes:
sideshowbarker
2024-07-17 18:52:11 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/e37e4a7980 Pull-request: https://github.com/SerenityOS/serenity/pull/12507
3 changed files with 5 additions and 4 deletions
|
@ -130,10 +130,11 @@ ErrorOr<void> Inode::decrement_link_count()
|
|||
return ENOTIMPL;
|
||||
}
|
||||
|
||||
void Inode::set_shared_vmobject(Memory::SharedInodeVMObject& vmobject)
|
||||
ErrorOr<void> Inode::set_shared_vmobject(Memory::SharedInodeVMObject& vmobject)
|
||||
{
|
||||
MutexLocker locker(m_inode_lock);
|
||||
m_shared_vmobject = vmobject;
|
||||
m_shared_vmobject = TRY(vmobject.try_make_weak_ptr<Memory::SharedInodeVMObject>());
|
||||
return {};
|
||||
}
|
||||
|
||||
RefPtr<LocalSocket> Inode::bound_socket() const
|
||||
|
|
|
@ -82,7 +82,7 @@ public:
|
|||
|
||||
void will_be_destroyed();
|
||||
|
||||
void set_shared_vmobject(Memory::SharedInodeVMObject&);
|
||||
ErrorOr<void> set_shared_vmobject(Memory::SharedInodeVMObject&);
|
||||
RefPtr<Memory::SharedInodeVMObject> shared_vmobject() const;
|
||||
|
||||
static void sync_all();
|
||||
|
|
|
@ -18,7 +18,7 @@ ErrorOr<NonnullRefPtr<SharedInodeVMObject>> SharedInodeVMObject::try_create_with
|
|||
auto new_physical_pages = TRY(VMObject::try_create_physical_pages(size));
|
||||
auto dirty_pages = TRY(Bitmap::try_create(new_physical_pages.size(), false));
|
||||
auto vmobject = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) SharedInodeVMObject(inode, move(new_physical_pages), move(dirty_pages))));
|
||||
vmobject->inode().set_shared_vmobject(*vmobject);
|
||||
TRY(vmobject->inode().set_shared_vmobject(*vmobject));
|
||||
return vmobject;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue