On Tue, Jan 04, 2022 at 10:58:41AM +0100, Claudio Jeker wrote: > This are obvious and easy to fix unused but set variables. > There are more in vioscsi.c but those are actually used if compiled with > DEBUG set.
The changes in loadfile_elf.c, vioqcow2.c and vmd.c are trivial and can be committed one by one. The change in vmm.c actually uncovered a possible issue. If vm_register() fails the vm pointer will most probably be NULL and so the next line will access a NULL pointer. I think this diff is better. It cleans up also a totally unused IMSG_VMDOP_RECEIVE_VM_RESPONSE imsg type. It is hard to fail the vm_register() call so it is not trivial to really test the error case but I did test vmctl receive and that still works. -- :wq Claudio Index: control.c =================================================================== RCS file: /cvs/src/usr.sbin/vmd/control.c,v retrieving revision 1.38 diff -u -p -r1.38 control.c --- control.c 29 Nov 2021 05:17:35 -0000 1.38 +++ control.c 4 Jan 2022 12:05:35 -0000 @@ -94,7 +94,6 @@ control_dispatch_vmd(int fd, struct priv case IMSG_VMDOP_START_VM_RESPONSE: case IMSG_VMDOP_PAUSE_VM_RESPONSE: case IMSG_VMDOP_SEND_VM_RESPONSE: - case IMSG_VMDOP_RECEIVE_VM_RESPONSE: case IMSG_VMDOP_UNPAUSE_VM_RESPONSE: case IMSG_VMDOP_GET_INFO_VM_DATA: case IMSG_VMDOP_GET_INFO_VM_END_DATA: Index: vmd.h =================================================================== RCS file: /cvs/src/usr.sbin/vmd/vmd.h,v retrieving revision 1.107 diff -u -p -r1.107 vmd.h --- vmd.h 29 Nov 2021 05:17:35 -0000 1.107 +++ vmd.h 4 Jan 2022 12:05:24 -0000 @@ -101,7 +101,6 @@ enum imsg_type { IMSG_VMDOP_SEND_VM_REQUEST, IMSG_VMDOP_SEND_VM_RESPONSE, IMSG_VMDOP_RECEIVE_VM_REQUEST, - IMSG_VMDOP_RECEIVE_VM_RESPONSE, IMSG_VMDOP_RECEIVE_VM_END, IMSG_VMDOP_WAIT_VM_REQUEST, IMSG_VMDOP_TERMINATE_VM_REQUEST, Index: vmm.c =================================================================== RCS file: /cvs/src/usr.sbin/vmd/vmm.c,v retrieving revision 1.102 diff -u -p -r1.102 vmm.c --- vmm.c 29 Nov 2021 05:17:35 -0000 1.102 +++ vmm.c 4 Jan 2022 12:05:04 -0000 @@ -102,7 +102,7 @@ int vmm_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg) { struct privsep *ps = p->p_ps; - int res = 0, cmd = 0, verbose, ret; + int res = 0, cmd = 0, verbose; struct vmd_vm *vm = NULL; struct vm_terminate_params vtp; struct vmop_id vid; @@ -278,8 +278,12 @@ vmm_dispatch_parent(int fd, struct privs case IMSG_VMDOP_RECEIVE_VM_REQUEST: IMSG_SIZE_CHECK(imsg, &vmc); memcpy(&vmc, imsg->data, sizeof(vmc)); - ret = vm_register(ps, &vmc, &vm, - imsg->hdr.peerid, vmc.vmc_owner.uid); + if (vm_register(ps, &vmc, &vm, + imsg->hdr.peerid, vmc.vmc_owner.uid) != 0) { + res = errno; + cmd = IMSG_VMDOP_START_VM_RESPONSE; + break; + } vm->vm_tty = imsg->fd; vm->vm_state |= VM_STATE_RECEIVED; vm->vm_state |= VM_STATE_PAUSED; @@ -328,6 +332,7 @@ vmm_dispatch_parent(int fd, struct privs } if (id == 0) id = imsg->hdr.peerid; + /* FALLTHROUGH */ case IMSG_VMDOP_PAUSE_VM_RESPONSE: case IMSG_VMDOP_UNPAUSE_VM_RESPONSE: case IMSG_VMDOP_TERMINATE_VM_RESPONSE: