Skip to content

Commit efbdeb2

Browse files
[dfs]释放fd_slot之前将子节点释放避免内存泄漏 (#7378)
1 parent 62dcc50 commit efbdeb2

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

components/dfs/dfs_v1/src/dfs.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,11 @@ void fdt_fd_release(struct dfs_fdtable* fdt, int fd)
359359
if (vnode)
360360
{
361361
vnode->ref_count--;
362+
if(vnode->ref_count == 0)
363+
{
364+
rt_free(vnode);
365+
fd_slot->vnode = RT_NULL;
366+
}
362367
}
363368
rt_free(fd_slot);
364369
}

components/dfs/dfs_v2/src/dfs.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,11 @@ void fdt_fd_release(struct dfs_fdtable* fdt, int fd)
359359
if (vnode)
360360
{
361361
vnode->ref_count--;
362+
if(vnode->ref_count == 0)
363+
{
364+
rt_free(vnode);
365+
fd_slot->vnode = RT_NULL;
366+
}
362367
}
363368
rt_free(fd_slot);
364369
}

0 commit comments

Comments
 (0)