From ed010ab236dbe222811a41dc421aae6e59864e99 Mon Sep 17 00:00:00 2001 From: dv Date: Sun, 10 Apr 2022 19:36:58 +0000 Subject: [PATCH] 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@. --- usr.sbin/vmd/vmm.c | 12 +++++++----- 1 file 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 @@ -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); } -- 2.20.1