diff options
author | 2015-12-01 12:03:55 +0000 | |
---|---|---|
committer | 2015-12-01 12:03:55 +0000 | |
commit | bbb36cb4c106df3f54ab1dbd77f47c568627f08a (patch) | |
tree | a7e17706a9e7319835c84da6c9a7946f625d2cdf | |
parent | Undo previous, pledge("dns") was already present. The problem was in s_server. (diff) | |
download | wireguard-openbsd-bbb36cb4c106df3f54ab1dbd77f47c568627f08a.tar.xz wireguard-openbsd-bbb36cb4c106df3f54ab1dbd77f47c568627f08a.zip |
Pass M_NOWAIT when allocating a temporary page in vm_writepage() to be
coherent with the rest of the allocations.
While here report the correct errno if an allocation fails.
ok mlarkin@
-rw-r--r-- | sys/arch/amd64/amd64/vmm.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/sys/arch/amd64/amd64/vmm.c b/sys/arch/amd64/amd64/vmm.c index 2fd5d96dadd..9ef52a67dd0 100644 --- a/sys/arch/amd64/amd64/vmm.c +++ b/sys/arch/amd64/amd64/vmm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmm.c,v 1.14 2015/12/01 12:01:38 mpi Exp $ */ +/* $OpenBSD: vmm.c,v 1.15 2015/12/01 12:03:55 mpi Exp $ */ /* * Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org> * @@ -472,9 +472,8 @@ vm_writepage(struct vm_writepage_params *vwp) } /* Allocate temporary region to copyin into */ - pagedata = malloc(PAGE_SIZE, M_DEVBUF, M_WAITOK | M_ZERO); - - if (!pagedata) { + pagedata = malloc(PAGE_SIZE, M_DEVBUF, M_NOWAIT|M_ZERO); + if (pagedata == NULL) { rw_exit_read(&vmm_softc->vm_lock); return (ENOMEM); } @@ -505,11 +504,11 @@ vm_writepage(struct vm_writepage_params *vwp) /* Allocate kva for guest page */ kva = km_alloc(PAGE_SIZE, &kv_any, &kp_none, &kd_nowait); - if (!kva) { + if (kva == NULL) { DPRINTF("vm_writepage: can't alloc kva\n"); free(pagedata, M_DEVBUF, PAGE_SIZE); rw_exit_read(&vmm_softc->vm_lock); - return (EFAULT); + return (ENOMEM); } /* Enter mapping and copy data */ |