From ba1ca6d2e3f7f94fa4a28ff67cdc1a28877e9fdc Mon Sep 17 00:00:00 2001 From: Sean Chittenden Date: Fri, 12 Jul 2019 18:20:56 +0000 Subject: [PATCH] usr.sbin/bhyve: free resources when erroring out of pci_vtcon_sock_add() Coverity CID: 1362880 Approved by: markj, jhb Differential Revision: https://reviews.freebsd.org/D20916 --- usr.sbin/bhyve/pci_virtio_console.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bhyve/pci_virtio_console.c b/usr.sbin/bhyve/pci_virtio_console.c index 556f08b6c33..a8883e07991 100644 --- a/usr.sbin/bhyve/pci_virtio_console.c +++ b/usr.sbin/bhyve/pci_virtio_console.c @@ -356,8 +356,11 @@ out: if (fd != -1) close(fd); - if (error != 0 && s != -1) - close(s); + if (error != 0) { + if (s != -1) + close(s); + free(sock); + } return (error); }