Author: seanc (ports committer) Date: Fri Jul 12 05:19:37 2019 New Revision: 349935 URL: https://svnweb.freebsd.org/changeset/base/349935
Log: usr.sbin/bhyve: free resources when erroring out of pci_vtnet_init() Coverity CID: 1402978 Approved by: vmaffione Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D20912 Modified: head/usr.sbin/bhyve/pci_virtio_net.c Modified: head/usr.sbin/bhyve/pci_virtio_net.c ============================================================================== --- head/usr.sbin/bhyve/pci_virtio_net.c Fri Jul 12 05:19:06 2019 (r349934) +++ head/usr.sbin/bhyve/pci_virtio_net.c Fri Jul 12 05:19:37 2019 (r349935) @@ -411,6 +411,7 @@ pci_vtnet_init(struct vmctx *ctx, struct pci_devinst * err = net_parsemac(vtopts, sc->vsc_config.mac); if (err != 0) { free(devname); + free(sc); return (err); } mac_provided = 1; @@ -419,8 +420,10 @@ pci_vtnet_init(struct vmctx *ctx, struct pci_devinst * err = netbe_init(&sc->vsc_be, devname, pci_vtnet_rx_callback, sc); free(devname); - if (err) + if (err) { + free(sc); return (err); + } sc->vsc_consts.vc_hv_caps |= netbe_get_cap(sc->vsc_be); } @@ -442,8 +445,10 @@ pci_vtnet_init(struct vmctx *ctx, struct pci_devinst * sc->vsc_vs.vs_mtx = &sc->vsc_mtx; /* use BAR 1 to map MSI-X table and PBA, if we're using MSI-X */ - if (vi_intr_init(&sc->vsc_vs, 1, fbsdrun_virtio_msix())) + if (vi_intr_init(&sc->vsc_vs, 1, fbsdrun_virtio_msix())) { + free(sc); return (1); + } /* use BAR 0 to map config regs in IO space */ vi_set_io_bar(&sc->vsc_vs, 0); _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"