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
This commit is contained in:
Sean Chittenden 2019-07-12 05:19:37 +00:00
parent 5603490248
commit c7cb7db87d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=349935

View File

@ -411,6 +411,7 @@ pci_vtnet_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts)
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 *pi, char *opts)
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 *pi, char *opts)
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);