From 88db52baebd10ab1c2643f214ab9d44edcdb0851 Mon Sep 17 00:00:00 2001 From: sotech117 Date: Thu, 25 Apr 2024 04:04:20 +0000 Subject: fix refcount issue --- kernel/proc/proc.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'kernel/proc/proc.c') diff --git a/kernel/proc/proc.c b/kernel/proc/proc.c index 1e38ca8..91be451 100644 --- a/kernel/proc/proc.c +++ b/kernel/proc/proc.c @@ -260,6 +260,20 @@ void proc_cleanup(long status) // NOT_YET_IMPLEMENTED("PROCS: proc_cleanup"); dbg(DBG_PROC, "proc_cleanup called on proc with pid=%d with exit status=%d\n", curproc->p_pid, status); +#ifdef __VFS__ + for (int fd = 0; fd < NFILES; fd++) + { + if (curproc->p_files[fd]) + { + fput(curproc->p_files + fd); + } + } + if (curproc->p_cwd) + { + vput(&curproc->p_cwd); + } +#endif + if (curproc->p_pid == PID_INIT) { @@ -289,20 +303,6 @@ void proc_cleanup(long status) // } else { curproc->p_status = status; // } - -#ifdef __VFS__ - for (int fd = 0; fd < NFILES; fd++) - { - if (curproc->p_files[fd]) - { - fput(curproc->p_files + fd); - } - } - if (curproc->p_cwd) - { - vput(&curproc->p_cwd); - } -#endif } /* -- cgit v1.2.3-70-g09d2