From 25a75e1b64e888aa4dc233efdd7ac52a0b73e324 Mon Sep 17 00:00:00 2001 From: dv Date: Sun, 4 Feb 2024 14:56:45 +0000 Subject: [PATCH] Prevent null pointer deref is vm isn't found. This area of code in vmd(8) is suspect, but the null dereference is easily avoided. Found by smatch, reported by and ok jsg@ --- usr.sbin/vmd/vmd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/usr.sbin/vmd/vmd.c b/usr.sbin/vmd/vmd.c index 613cddebde3..f821b7e3c8f 100644 --- a/usr.sbin/vmd/vmd.c +++ b/usr.sbin/vmd/vmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmd.c,v 1.153 2024/01/18 14:49:59 claudio Exp $ */ +/* $OpenBSD: vmd.c,v 1.154 2024/02/04 14:56:45 dv Exp $ */ /* * Copyright (c) 2015 Reyk Floeter @@ -527,9 +527,8 @@ vmd_dispatch_vmm(int fd, struct privsep_proc *p, struct imsg *imsg) imsg->hdr.peerid == IMSG_AGENTX_PEERID ? PROC_AGENTX : PROC_CONTROL, -1, imsg->hdr.type, imsg->hdr.peerid, -1, &vir, sizeof(vir)) == -1) { - log_debug("%s: GET_INFO_VM failed for vm %d, removing", - __func__, vm->vm_vmid); - vm_terminate(vm, __func__); + if (vm) + vm_terminate(vm, __func__); return (-1); } break; -- 2.20.1