comment added

This commit is contained in:
2025-06-23 11:18:49 +08:00
parent c7c962ffef
commit 70ee668b9b
6 changed files with 34 additions and 8 deletions

View File

@@ -132,6 +132,7 @@ found:
return 0;
}
// 为进程分配 pre_trapframe 空间,分配失败则释放进程资源并返回 0
if((p->pre_trapframe = (struct trapframe *)kalloc()) == 0){
freeproc(p);
release(&p->lock);
@@ -166,6 +167,7 @@ freeproc(struct proc *p)
p->trapframe = 0;
if(p->pagetable)
proc_freepagetable(p->pagetable, p->sz);
// 如果进程的 pre_trapframe 存在,则释放其占用的内存,并将指针置为 0防止悬空指针。
if(p->pre_trapframe)
kfree((void*)p->pre_trapframe);
p->pre_trapframe = 0;