From 920dbd04588d869f0c2148a1be356533bfb3ce4c Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sat, 25 May 2024 23:20:34 -0400 Subject: kernel: vm: Fix vm_obj_destroy() - Set vp->vmobj to NULL *only* if vp is set - Refcount starts at 0, not 1 - Refcount check comes first Signed-off-by: Ian Moffett --- sys/vm/vm_obj.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/vm/vm_obj.c b/sys/vm/vm_obj.c index 6dbe777..b501c6b 100644 --- a/sys/vm/vm_obj.c +++ b/sys/vm/vm_obj.c @@ -74,13 +74,13 @@ vm_obj_destroy(struct vm_object *obj) { struct vnode *vp = obj->vnode; - if (vp->vmobj != NULL) - vp->vmobj = NULL; - /* Check the ref count */ - if (obj->ref > 1) + if (obj->ref > 0) return -EBUSY; + if (vp != NULL) + vp->vmobj = NULL; + dynfree(obj); --obj_count; return 0; -- cgit v1.2.3