File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed
components/dfs/dfs_v1/src Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -414,13 +414,16 @@ void fdt_fd_release(struct dfs_fdtable* fdt, int fd)
414414 if (fd_slot -> ref_count == 0 )
415415 {
416416 struct dfs_vnode * vnode = fd_slot -> vnode ;
417+ fd_slot -> vnode = RT_NULL ;
417418 if (vnode )
418419 {
419- vnode -> ref_count -- ;
420+ if (vnode -> ref_count > 0 )
421+ {
422+ vnode -> ref_count -- ;
423+ }
420424 if (vnode -> ref_count == 0 )
421425 {
422426 rt_free (vnode );
423- fd_slot -> vnode = RT_NULL ;
424427 }
425428 }
426429 rt_free (fd_slot );
Original file line number Diff line number Diff line change @@ -337,7 +337,7 @@ int dfs_file_close(struct dfs_file *fd)
337337 dfs_fm_lock ();
338338 vnode = fd -> vnode ;
339339
340- if (vnode -> ref_count <= 0 )
340+ if (vnode == NULL || vnode -> ref_count <= 0 )
341341 {
342342 dfs_fm_unlock ();
343343 return - ENXIO ;
@@ -348,11 +348,12 @@ int dfs_file_close(struct dfs_file *fd)
348348 result = vnode -> fops -> close (fd );
349349 }
350350
351- if (vnode -> ref_count == 1 )
351+ vnode -> ref_count -- ;
352+ fd -> vnode = NULL ;
353+ if (vnode -> ref_count == 0 )
352354 {
353355 /* remove from hash */
354356 rt_list_remove (& vnode -> list );
355- fd -> vnode = NULL ;
356357
357358 if (vnode -> path != vnode -> fullpath )
358359 {
You can’t perform that action at this time.
0 commit comments