summaryrefslogtreecommitdiff
path: root/kernel/fs/devfs.c
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2024-04-23 14:35:09 +0200
committerAnton Kling <anton@kling.gg>2024-04-23 14:35:09 +0200
commit0305b0abe4ada656462d575a5e0f0618b42def2d (patch)
treeecffe02ac3670457ed2cf0fbb513efbb69867d01 /kernel/fs/devfs.c
parent33663539c2bac856cf2abe79e815ad179dffecdf (diff)
VFS: Fix reference count of file descriptors.
It appears that there was a race condition where the process got closed before the server accepted the incoming request. Causing the file descriptor to have "0" in the reference count but it would still be given when calling accept.
Diffstat (limited to 'kernel/fs/devfs.c')
-rw-r--r--kernel/fs/devfs.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/fs/devfs.c b/kernel/fs/devfs.c
index a3f13db..c25c996 100644
--- a/kernel/fs/devfs.c
+++ b/kernel/fs/devfs.c
@@ -84,7 +84,8 @@ void add_stdout(void) {
}
vfs_inode_t *devfs_mount(void) {
- vfs_inode_t *root = kmalloc(sizeof(vfs_inode_t));
+ vfs_inode_t *root = kcalloc(1, sizeof(vfs_inode_t));
+ root->ref++;
root->open = devfs_open;
root->read = devfs_read;
root->write = devfs_write;