vfs: fix edge case when returned fd is null
This commit is contained in:
parent
dc8f7126dc
commit
7f13dbfa16
1 changed files with 5 additions and 0 deletions
5
fs/vfs.c
5
fs/vfs.c
|
|
@ -156,6 +156,11 @@ DIR *opendir(const char *name)
|
||||||
if (!fdesc)
|
if (!fdesc)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if (fdesc->fd < 0) {
|
||||||
|
slab_free(fd_slab, fdesc);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
struct fs *fs = fdesc->fs;
|
struct fs *fs = fdesc->fs;
|
||||||
|
|
||||||
if ((fdesc->vnode.flags & VFS_VTYPE_MASK) != VFS_VNO_DIR) {
|
if ((fdesc->vnode.flags & VFS_VTYPE_MASK) != VFS_VNO_DIR) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue