diff options
author | Dave Voutila <dv@cvs.openbsd.org> | 2022-04-10 19:36:59 +0000 |
---|---|---|
committer | Dave Voutila <dv@cvs.openbsd.org> | 2022-04-10 19:36:59 +0000 |
commit | a72e2595cab8c94b63ff22a19c7c8098d9cc18b8 (patch) | |
tree | a8086c2945fd612efe41ef3506e3880acef8f4b3 | |
parent | 92256273725c2165bd095bf902f0ec0ab59cb345 (diff) |
Free vm_info_result in error paths.
vmd(8)'s get_info_vm() mallocs vm_info_result structs when using
the VMM_IOC_INFO ioctl. The error paths failed to free the resulting
objects.
Diff adapted from suggestions by jca@. ok mlarkin@.
-rw-r--r-- | usr.sbin/vmd/vmm.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.sbin/vmd/vmm.c b/usr.sbin/vmd/vmm.c index 10b0d0ffef0..fc6ced385bd 100644 --- a/usr.sbin/vmd/vmm.c +++ b/usr.sbin/vmd/vmm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmm.c,v 1.104 2022/03/01 21:46:19 dv Exp $ */ +/* $OpenBSD: vmm.c,v 1.105 2022/04/10 19:36:58 dv Exp $ */ /* * Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org> @@ -779,7 +779,7 @@ get_info_vm(struct privsep *ps, struct imsg *imsg, int terminate) if (terminate) { vtp.vtp_vm_id = info[i].vir_id; if ((ret = terminate_vm(&vtp)) != 0) - return (ret); + break; log_debug("%s: terminated vm %s (id %d)", __func__, info[i].vir_name, info[i].vir_id); continue; @@ -788,10 +788,12 @@ get_info_vm(struct privsep *ps, struct imsg *imsg, int terminate) vir.vir_info.vir_id = vm_id2vmid(info[i].vir_id, NULL); if (proc_compose_imsg(ps, PROC_PARENT, -1, IMSG_VMDOP_GET_INFO_VM_DATA, imsg->hdr.peerid, -1, - &vir, sizeof(vir)) == -1) - return (EIO); + &vir, sizeof(vir)) == -1) { + ret = EIO; + break; + } } free(info); - return (0); + return (ret); } |