From bc928800723b65daa9b005bec4ffd8ad8c781a09 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Mon, 28 Nov 2022 17:10:30 -0800 Subject: [PATCH] bhyve: Avoid passing a possible garbage pointer to free(). All of the error paths in pci_vtcon_sock_add free the sock pointer. However, sock is not initialized until part way through the function. An early error would pass stack garbage to free(). Reviewed by: corvink, markj Differential Revision: https://reviews.freebsd.org/D37491 --- usr.sbin/bhyve/pci_virtio_console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/bhyve/pci_virtio_console.c b/usr.sbin/bhyve/pci_virtio_console.c index 44d0da720226..46005d155f49 100644 --- a/usr.sbin/bhyve/pci_virtio_console.c +++ b/usr.sbin/bhyve/pci_virtio_console.c @@ -273,7 +273,7 @@ static int pci_vtcon_sock_add(struct pci_vtcon_softc *sc, const char *port_name, const nvlist_t *nvl) { - struct pci_vtcon_sock *sock; + struct pci_vtcon_sock *sock = NULL; struct sockaddr_un sun; const char *name, *path; char *cp, *pathcopy;