summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-09-07 20:10:06 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-07 22:16:25 +0200
commit049d846eb9964c8ea305e801d46bb61791809c6e (patch)
tree64c4200f899f1ad0c3cdc91cf4bc2cd2d44bbd1a /Kernel/FileSystem
parente550d53c0f10f9087bbfb925edb22d3d5af2e36f (diff)
downloadserenity-049d846eb9964c8ea305e801d46bb61791809c6e.zip
Kernel/TmpFS: Stop leaking directory entry metadata
When creating and removing a child to a TmpFS directory, we were forgetting to delete the TmpFSInode::Child struct.
Diffstat (limited to 'Kernel/FileSystem')
-rw-r--r--Kernel/FileSystem/TmpFS.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/Kernel/FileSystem/TmpFS.cpp b/Kernel/FileSystem/TmpFS.cpp
index 69df11c9ee..f1e43397e2 100644
--- a/Kernel/FileSystem/TmpFS.cpp
+++ b/Kernel/FileSystem/TmpFS.cpp
@@ -277,6 +277,7 @@ KResult TmpFSInode::add_child(Inode& child, StringView const& name, mode_t)
return ENAMETOOLONG;
auto name_kstring = TRY(KString::try_create(name));
+ // Balanced by `delete` in remove_child()
auto* child_entry = new (nothrow) Child { move(name_kstring), static_cast<TmpFSInode&>(child) };
if (!child_entry)
return ENOMEM;
@@ -303,6 +304,8 @@ KResult TmpFSInode::remove_child(StringView const& name)
child->inode->did_delete_self();
m_children.remove(*child);
did_remove_child(child_id, name);
+ // Balanced by `new` in add_child()
+ delete child;
return KSuccess;
}