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
This commit is contained in:
John Baldwin 2022-11-28 17:10:30 -08:00
parent 32b21dd271
commit bc92880072

View File

@ -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;