diff options
author | Anton Kling <anton@kling.gg> | 2024-04-23 14:35:09 +0200 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2024-04-23 14:35:09 +0200 |
commit | 0305b0abe4ada656462d575a5e0f0618b42def2d (patch) | |
tree | ecffe02ac3670457ed2cf0fbb513efbb69867d01 /kernel/fs/vfs.c | |
parent | 33663539c2bac856cf2abe79e815ad179dffecdf (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/vfs.c')
-rw-r--r-- | kernel/fs/vfs.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/kernel/fs/vfs.c b/kernel/fs/vfs.c index bcc0ce5..a55f78c 100644 --- a/kernel/fs/vfs.c +++ b/kernel/fs/vfs.c @@ -55,7 +55,7 @@ vfs_inode_t *vfs_create_inode( r->truncate = truncate; r->stat = stat; r->send_signal = send_signal; - r->ref = 1; + r->ref = 0; return r; } @@ -415,11 +415,13 @@ int vfs_dup2(int org_fd, int new_fd) { assert(0); return -1; } + assert(1 <= orig->reference_count); if (!list_set(¤t_task->file_descriptors, new_fd, orig)) { assert(0); return -1; } orig->reference_count++; + assert(2 <= orig->reference_count); return 1; } |