[dfs]释放fd_slot之前将子节点释放避免内存泄漏 (#7378)

This commit is contained in:
goldengrandpa 2023-04-26 08:47:21 +08:00 committed by GitHub
parent 62dcc50530
commit efbdeb25ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -359,6 +359,11 @@ void fdt_fd_release(struct dfs_fdtable* fdt, int fd)
if (vnode)
{
vnode->ref_count--;
if(vnode->ref_count == 0)
{
rt_free(vnode);
fd_slot->vnode = RT_NULL;
}
}
rt_free(fd_slot);
}

View File

@ -359,6 +359,11 @@ void fdt_fd_release(struct dfs_fdtable* fdt, int fd)
if (vnode)
{
vnode->ref_count--;
if(vnode->ref_count == 0)
{
rt_free(vnode);
fd_slot->vnode = RT_NULL;
}
}
rt_free(fd_slot);
}