ref: 2b323158bd8f2a1e1f86796e0bb0139e0c77dace
parent: cf8f90e1d3bc60842e9ca25b6339e80c4d75a828
parent: 019bb580da25ccfb414c9b71ce5c0743cf86d6fd
author: cinap_lenrek <[email protected]>
date: Sun Mar 26 12:46:58 EDT 2017
merge
--- a/sys/src/9/pc/sdvirtio.c
+++ b/sys/src/9/pc/sdvirtio.c
@@ -579,7 +579,7 @@
snprint(name, sizeof(name), "%s (%s)", sd->name, sd->ifc->name);
intrenable(vd->pci->intl, viointerrupt, vd, vd->pci->tbdf, name);
outb(vd->port+Status, inb(vd->port+Status) | DriverOk);
- return 0;
+ return 1;
}
static int
@@ -591,7 +591,7 @@
vd = sd->ctlr;
snprint(name, sizeof(name), "%s (%s)", sd->name, sd->ifc->name);
intrdisable(vd->pci->intl, viointerrupt, vd, vd->pci->tbdf, name);
- return 0;
+ return 1;
}
static SDev*
--- a/sys/src/9/port/devsd.c
+++ b/sys/src/9/port/devsd.c
@@ -293,12 +293,12 @@
qunlock(&sdev->unitlock);
return nil;
}
+
if((unit = malloc(sizeof(SDunit))) == nil){
qunlock(&sdev->unitlock);
return nil;
}
sdev->unitflg[subno] = 1;
-
snprint(buf, sizeof buf, "%s%x", sdev->name, subno);
kstrdup(&unit->name, buf);
kstrdup(&unit->user, eve);
@@ -305,10 +305,9 @@
unit->perm = 0555;
unit->subno = subno;
unit->dev = sdev;
-
+
if(sdev->enabled == 0 && sdev->ifc->enable)
- sdev->ifc->enable(sdev);
- sdev->enabled = 1;
+ sdev->enabled = sdev->ifc->enable(sdev);
/*
* No need to lock anything here as this is only
@@ -315,8 +314,10 @@
* called before the unit is made available in the
* sdunit[] array.
*/
- if(unit->dev->ifc->verify(unit) == 0){
+ if(sdev->enabled == 0 || unit->dev->ifc->verify(unit) == 0){
qunlock(&sdev->unitlock);
+ free(unit->name);
+ free(unit->user);
free(unit);
return nil;
}