From 726e47bb80d83fe6af11edd409e5949d66102b9e Mon Sep 17 00:00:00 2001 From: Siarzhuk Zharski Date: Tue, 10 Sep 2013 19:47:36 +0200 Subject: [PATCH] vfs:Remove extra put_vnode call on error B_LINK_LIMIT exit Fixing the autoconf test: attempt to create file in place of already existing symlink. On error exit put_vnode was called explicitly before returning error. The second, implicit call to put_vnode was issued on destroying the VNodePutter instance that references the same vnode. At this time the vnode has references count equal to 0 so corresponding panic was executed. Great thanks to Ingo for pointing it out! Fixes #9140. --- src/system/kernel/fs/vfs.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/system/kernel/fs/vfs.cpp b/src/system/kernel/fs/vfs.cpp index 0b5371b89d..91707333c4 100644 --- a/src/system/kernel/fs/vfs.cpp +++ b/src/system/kernel/fs/vfs.cpp @@ -5260,10 +5260,8 @@ create_vnode(struct vnode* directory, const char* name, int openMode, putter.SetTo(vnode); } - if ((openMode & O_NOFOLLOW) != 0 && S_ISLNK(vnode->Type())) { - put_vnode(vnode); + if ((openMode & O_NOFOLLOW) != 0 && S_ISLNK(vnode->Type())) return B_LINK_LIMIT; - } int fd = open_vnode(vnode, openMode & ~O_CREAT, kernel); // on success keep the vnode reference for the FD