aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-05-25 23:20:34 -0400
committerIan Moffett <ian@osmora.org>2024-05-25 23:24:05 -0400
commit920dbd04588d869f0c2148a1be356533bfb3ce4c (patch)
tree408b33f8cc3d41f5ad4da3e819f96f1fbff8e81e /sys
parent94d6ea02c510ca3752d9667dac13bfb16ab2ee2c (diff)
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 <ian@osmora.org>
Diffstat (limited to 'sys')
-rw-r--r--sys/vm/vm_obj.c8
1 files 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;