summaryrefslogtreecommitdiff
path: root/components/dfs
diff options
context:
space:
mode:
Diffstat (limited to 'components/dfs')
-rw-r--r--components/dfs/src/dfs.c7
-rw-r--r--components/dfs/src/dfs_posix.c7
2 files changed, 7 insertions, 7 deletions
diff --git a/components/dfs/src/dfs.c b/components/dfs/src/dfs.c
index 86ef809fbf..fe0020b277 100644
--- a/components/dfs/src/dfs.c
+++ b/components/dfs/src/dfs.c
@@ -153,6 +153,13 @@ struct dfs_fd *fd_get(int fd)
dfs_lock();
d = &fd_table[fd];
+ /* check dfs_fd valid or not */
+ if (d->path == RT_NULL || d->fs == RT_NULL)
+ {
+ dfs_unlock();
+ return RT_NULL;
+ }
+
/* increase the reference count */
d->ref_count ++;
dfs_unlock();
diff --git a/components/dfs/src/dfs_posix.c b/components/dfs/src/dfs_posix.c
index d658f08265..2ccc1541d5 100644
--- a/components/dfs/src/dfs_posix.c
+++ b/components/dfs/src/dfs_posix.c
@@ -86,13 +86,6 @@ int close(int fd)
return -1;
}
- /* check dfs_fd valid or not */
- if (d->path == RT_NULL || d->ref_count == 0)
- {
- rt_set_errno(-DFS_STATUS_EBADF);
- return -1;
- }
-
result = dfs_file_close(d);
fd_put(d);