diff options
author | 2016-11-22 22:51:45 +0000 | |
---|---|---|
committer | 2016-11-22 22:51:45 +0000 | |
commit | d3b18ed24d881cb9fdb16b54253d314c3dddba13 (patch) | |
tree | bb880215185982de9a096b2a65824a98a71153e7 | |
parent | Add "features request" support and reply validation. (diff) | |
download | wireguard-openbsd-d3b18ed24d881cb9fdb16b54253d314c3dddba13.tar.xz wireguard-openbsd-d3b18ed24d881cb9fdb16b54253d314c3dddba13.zip |
Don't attempt to call vm_remove() with a NULL vm: some functions like
config_getvm() already removed the vm on failure!
Found by mlarkin@
-rw-r--r-- | usr.sbin/vmd/vmm.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/usr.sbin/vmd/vmm.c b/usr.sbin/vmd/vmm.c index 687ef69202f..226b8ceefa4 100644 --- a/usr.sbin/vmd/vmm.c +++ b/usr.sbin/vmd/vmm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmm.c,v 1.54 2016/11/04 15:07:26 reyk Exp $ */ +/* $OpenBSD: vmm.c,v 1.55 2016/11/22 22:51:45 reyk Exp $ */ /* * Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org> @@ -219,9 +219,9 @@ vmm_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg) res = terminate_vm(&vtp); cmd = IMSG_VMDOP_TERMINATE_VM_RESPONSE; if (res == 0) { - /* Remove local reference */ - vm = vm_getbyid(id); - vm_remove(vm); + /* Remove local reference if it exists */ + if ((vm = vm_getbyid(id)) != NULL) + vm_remove(vm); } break; case IMSG_VMDOP_GET_INFO_VM_REQUEST: @@ -249,8 +249,9 @@ vmm_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg) break; case IMSG_VMDOP_START_VM_RESPONSE: if (res != 0) { - vm = vm_getbyvmid(imsg->hdr.peerid); - vm_remove(vm); + /* Remove local reference if it exists */ + if ((vm = vm_getbyvmid(imsg->hdr.peerid)) != NULL) + vm_remove(vm); } case IMSG_VMDOP_TERMINATE_VM_RESPONSE: memset(&vmr, 0, sizeof(vmr)); |