提交 1957f738 编写于 作者: F Far

fix: lookup new vnode may cause freeing parent vnode

Close #I3MYP4

Change-Id: I03b19a74ae5340aa6c7cdc84d044c469873c1648
上级 bf2478ca
......@@ -225,14 +225,17 @@ int fp_open(char *fullpath, int oflags, mode_t mode)
if ((ret != OK) && (oflags & O_CREAT) && vnode)
{
vnode->useCount++;
/* if file not exist, but parent dir of the file is exist */
if (VfsVnodePermissionCheck(vnode, (WRITE_OP | EXEC_OP)))
{
ret = -EACCES;
vnode->useCount--;
VnodeDrop();
goto errout_without_count;
}
ret = do_creat(&vnode, fullpath, mode);
vnode->useCount--;
if (ret != OK)
{
VnodeDrop();
......
......@@ -196,7 +196,9 @@ int do_rename(int oldfd, const char *oldpath, int newfd, const char *newpath)
ret = -ENOSYS;
goto errout_with_vnode;
}
new_parent_vnode->useCount++;
ret = old_vnode->vop->Rename(old_vnode, new_parent_vnode, oldname, newname);
new_parent_vnode->useCount--;
if (ret < 0)
{
goto errout_with_vnode;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册