diff --git a/components/dfs/dfs_v1/src/dfs.c b/components/dfs/dfs_v1/src/dfs.c index ecab062d7ac..5487b1c012c 100644 --- a/components/dfs/dfs_v1/src/dfs.c +++ b/components/dfs/dfs_v1/src/dfs.c @@ -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); } diff --git a/components/dfs/dfs_v2/src/dfs.c b/components/dfs/dfs_v2/src/dfs.c index ecab062d7ac..5487b1c012c 100644 --- a/components/dfs/dfs_v2/src/dfs.c +++ b/components/dfs/dfs_v2/src/dfs.c @@ -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); }