git: bc928800723b - main - bhyve: Avoid passing a possible garbage pointer to free().

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Tue, 29 Nov 2022 01:11:01 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=bc928800723b65daa9b005bec4ffd8ad8c781a09

commit bc928800723b65daa9b005bec4ffd8ad8c781a09
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-11-29 01:10:30 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-11-29 01:10:30 +0000

    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;