From 19c48aa4ae39e2b2ff84224e66b9f8e7b0280c3f Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Tue, 21 Jun 2011 23:24:23 +0200 Subject: [PATCH] fix_dirent(): Fix ref count leaks * Only get an additional parent reference, when going to call vnode_path_to_vnode(). * Put the reference of the vnode vnode_path_to_vnode() returns. --- src/system/kernel/fs/vfs.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/system/kernel/fs/vfs.cpp b/src/system/kernel/fs/vfs.cpp index e6bdb00175..d4c14f85de 100644 --- a/src/system/kernel/fs/vfs.cpp +++ b/src/system/kernel/fs/vfs.cpp @@ -5780,14 +5780,14 @@ fix_dirent(struct vnode* parent, struct dirent* entry, // If this is the ".." entry and the directory covering another vnode, // we need to replace d_dev and d_ino with the actual values. if (strcmp(entry->d_name, "..") == 0 && parent->IsCovering()) { - inc_vnode_ref_count(parent); - // vnode_path_to_vnode() puts the node - // Make sure the IO context root is not bypassed. if (parent == ioContext->root) { entry->d_dev = parent->device; entry->d_ino = parent->id; } else { + inc_vnode_ref_count(parent); + // vnode_path_to_vnode() puts the node + // ".." is guaranteed not to be clobbered by this call struct vnode* vnode; status_t status = vnode_path_to_vnode(parent, (char*)"..", false, 0, @@ -5796,6 +5796,7 @@ fix_dirent(struct vnode* parent, struct dirent* entry, if (status == B_OK) { entry->d_dev = vnode->device; entry->d_ino = vnode->id; + put_vnode(vnode); } } } else {