From 852b00cbc75b83390984a77048e443a43dd0ae48 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Fri, 19 Apr 2024 22:08:50 -0400 Subject: kernel: vm: Add vm_object refcount Signed-off-by: Ian Moffett --- sys/vm/vm_obj.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sys/vm') diff --git a/sys/vm/vm_obj.c b/sys/vm/vm_obj.c index 589ca47..7487b47 100644 --- a/sys/vm/vm_obj.c +++ b/sys/vm/vm_obj.c @@ -59,6 +59,7 @@ vm_obj_init(struct vm_object **res, struct vnode *vnode) memset(obj, 0, sizeof(struct vm_object)); obj->vnode = vnode; + obj->ref = 1; vm_set_pgops(obj, vnode); *res = obj; @@ -73,6 +74,10 @@ vm_obj_destroy(struct vm_object *obj) if (vp->vmobj != NULL) vp->vmobj = NULL; + /* Check the ref count */ + if (obj->ref > 1) + return -EBUSY; + dynfree(obj); return 0; } -- cgit v1.2.3