devkbd: fix wrong refcount on open error
only decrement refcount when file was successfully opend on clunk, fix refcount when devopen() errors.
This commit is contained in:
parent
5e37e6361c
commit
244d2ee84b
1 changed files with 8 additions and 3 deletions
|
@ -339,10 +339,15 @@ kbdopen(Chan *c, int omode)
|
||||||
if(!iseve())
|
if(!iseve())
|
||||||
error(Eperm);
|
error(Eperm);
|
||||||
if(c->qid.path == Qscancode){
|
if(c->qid.path == Qscancode){
|
||||||
if(incref(&kbd.ref) != 1){
|
if(waserror()){
|
||||||
decref(&kbd.ref);
|
decref(&kbd.ref);
|
||||||
error(Einuse);
|
nexterror();
|
||||||
}
|
}
|
||||||
|
if(incref(&kbd.ref) != 1)
|
||||||
|
error(Einuse);
|
||||||
|
c = devopen(c, omode, kbdtab, nelem(kbdtab), devgen);
|
||||||
|
poperror();
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
return devopen(c, omode, kbdtab, nelem(kbdtab), devgen);
|
return devopen(c, omode, kbdtab, nelem(kbdtab), devgen);
|
||||||
}
|
}
|
||||||
|
@ -350,7 +355,7 @@ kbdopen(Chan *c, int omode)
|
||||||
static void
|
static void
|
||||||
kbdclose(Chan *c)
|
kbdclose(Chan *c)
|
||||||
{
|
{
|
||||||
if(c->qid.path == Qscancode)
|
if((c->flag & COPEN) && c->qid.path == Qscancode)
|
||||||
decref(&kbd.ref);
|
decref(&kbd.ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue