vfs: fix edge case when returned fd is null

This commit is contained in:
Michael Shaw 2023-12-03 22:58:24 -05:00
commit 7f13dbfa16

View file

@ -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) {