sdvirtio: be more carefull at wakeup
wakeup cannot access r->sleep once we set r->done because the sleeper might just return at this point making r invalid. make a copy of the sleep rendez pointer before setting r->done.
This commit is contained in:
parent
8e5dd37eba
commit
80a5bfc1d8
1 changed files with 5 additions and 2 deletions
|
@ -218,6 +218,7 @@ viointerrupt(Ureg *, void *arg)
|
|||
{
|
||||
int id, free, m;
|
||||
struct Rock *r;
|
||||
Rendez *z;
|
||||
Vqueue *q;
|
||||
Vdev *vd;
|
||||
|
||||
|
@ -231,8 +232,10 @@ viointerrupt(Ureg *, void *arg)
|
|||
id = q->usedent[q->lastused++ & m].id;
|
||||
if(r = q->rock[id]){
|
||||
q->rock[id] = nil;
|
||||
r->done = 1;
|
||||
wakeup(r->sleep);
|
||||
z = r->sleep;
|
||||
r->done = 1; /* hands off */
|
||||
if(z != nil)
|
||||
wakeup(z);
|
||||
}
|
||||
do {
|
||||
free = id;
|
||||
|
|
Loading…
Reference in a new issue