提交 32c27657 编写于 作者: F Far 提交者: Gitee

fix: BCHR-type vnode may be reclaimed before vnodefree

Decreasing a vnode of BCHR type, drop the vnode mutex , and then check the vnode and hold the mutex again makes it possible to reclaim the vnode by other threads before free the vnode, which may cause problems

Close #I3ORVN 
上级 8812f7fe
......@@ -186,20 +186,18 @@ static int _files_close(struct file *filep)
}
VnodeHold();
vnode->useCount--;
VnodeDrop();
}
/* Block char device is removed when close */
if (vnode->type == VNODE_TYPE_BCHR)
{
VnodeHold();
ret = VnodeFree(vnode);
if (ret < 0)
/* Block char device is removed when close */
if (vnode->type == VNODE_TYPE_BCHR)
{
PRINTK("Removing bchar device %s failed\n", filep->f_path);
ret = VnodeFree(vnode);
if (ret < 0)
{
PRINTK("Removing bchar device %s failed\n", filep->f_path);
}
}
VnodeDrop();
}
/* Release the path of file */
free(filep->f_path);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册