mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-16 15:11:52 +00:00
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
This commit is contained in:
parent
ba1ca6d2e3
commit
dbb1521165
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=349947
@ -668,14 +668,14 @@ passthru_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts)
|
||||
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 *pi, char *opts)
|
||||
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 *pi, char *opts)
|
||||
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 *pi, char *opts)
|
||||
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 *pi, char *opts)
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user