aboutsummaryrefslogtreecommitdiff
path: root/sys/vm/vm_fault.c
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-05-07 00:14:29 -0400
committerIan Moffett <ian@osmora.org>2024-05-07 00:14:29 -0400
commit69c9009e60ab1e9ab11c4e8d0ab11a4f0c2c6d8e (patch)
tree886fe839a2679a34cd84e3f2ec7e766aafd96269 /sys/vm/vm_fault.c
parenteeac9e1436d961e0103f5125794e050758a91670 (diff)
kernel: vm_fault: Ref vmobj before usage
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/vm/vm_fault.c')
-rw-r--r--sys/vm/vm_fault.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c
index 219db91..45def7f 100644
--- a/sys/vm/vm_fault.c
+++ b/sys/vm/vm_fault.c
@@ -101,6 +101,7 @@ vm_fault(vaddr_t va, vm_prot_t access_type)
struct vm_mapping *mapping;
struct vm_object *vmobj;
+ int s = 0;
size_t granule = vm_get_page_size();
vaddr_t va_base = va & ~(granule - 1);
@@ -115,11 +116,17 @@ vm_fault(vaddr_t va, vm_prot_t access_type)
/* Invalid access type */
return -1;
+ vm_object_ref(vmobj);
+
/* Can we perform demand paging? */
if (vmobj->demand) {
- if (vm_demand_page(mapping, va_base, access_type) != 0)
- return -1;
+ s = vm_demand_page(mapping, va_base, access_type);
+ if (s != 0)
+ goto done;
}
- return 0;
+done:
+ /* Drop the vmobj ref */
+ vm_object_unref(vmobj);
+ return s;
}