svn commit: r349947 - head/usr.sbin/bhyve

Sean Chittenden seanc at FreeBSD.org
Fri Jul 12 18:33:59 UTC 2019


Author: seanc (ports committer)
Date: Fri Jul 12 18:33:58 2019
New Revision: 349947
URL: https://svnweb.freebsd.org/changeset/base/349947

Log:
  usr.sbin/bhyve: only unassign a pt device after obtaining bus/slot/func
  
  Coverity CID:	1194302, 1194303, 1194304
  Approved by:	jhb, markj
  Differential Revision:	https://reviews.freebsd.org/D20933

Modified:
  head/usr.sbin/bhyve/pci_passthru.c

Modified: head/usr.sbin/bhyve/pci_passthru.c
==============================================================================
--- head/usr.sbin/bhyve/pci_passthru.c	Fri Jul 12 18:20:56 2019	(r349946)
+++ head/usr.sbin/bhyve/pci_passthru.c	Fri Jul 12 18:33:58 2019	(r349947)
@@ -668,14 +668,14 @@ passthru_init(struct vmctx *ctx, struct pci_devinst *p
 	memflags = vm_get_memflags(ctx);
 	if (!(memflags & VM_MEM_F_WIRED)) {
 		warnx("passthru requires guest memory to be wired");
-		goto done;
+		return (error);
 	}
 
 	if (pcifd < 0) {
 		pcifd = open(_PATH_DEVPCI, O_RDWR, 0);
 		if (pcifd < 0) {
 			warn("failed to open %s", _PATH_DEVPCI);
-			goto done;
+			return (error);
 		}
 	}
 
@@ -690,7 +690,7 @@ passthru_init(struct vmctx *ctx, struct pci_devinst *p
 		iofd = open(_PATH_DEVIO, O_RDWR, 0);
 		if (iofd < 0) {
 			warn("failed to open %s", _PATH_DEVIO);
-			goto done;
+			return (error);
 		}
 	}
 
@@ -705,7 +705,7 @@ passthru_init(struct vmctx *ctx, struct pci_devinst *p
 		memfd = open(_PATH_MEM, O_RDWR, 0);
 		if (memfd < 0) {
 			warn("failed to open %s", _PATH_MEM);
-			goto done;
+			return (error);
 		}
 	}
 
@@ -719,7 +719,7 @@ passthru_init(struct vmctx *ctx, struct pci_devinst *p
 	if (opts == NULL ||
 	    sscanf(opts, "%d/%d/%d", &bus, &slot, &func) != 3) {
 		warnx("invalid passthru options");
-		goto done;
+		return (error);
 	}
 
 	if (vm_assign_pptdev(ctx, bus, slot, func) != 0) {
@@ -734,10 +734,7 @@ passthru_init(struct vmctx *ctx, struct pci_devinst *p
 	sc->psc_pi = pi;
 
 	/* initialize config space */
-	if ((error = cfginit(ctx, pi, bus, slot, func)) != 0)
-		goto done;
-	
-	error = 0;		/* success */
+	error = cfginit(ctx, pi, bus, slot, func);
 done:
 	if (error) {
 		free(sc);


More information about the svn-src-all mailing list