devmouse: fix openmode() handling
openmode() can raise error with invalid mode passed, but we already incremented the exclusive mouse refcount at that point! call openmode() early to avoid this.
This commit is contained in:
parent
244d2ee84b
commit
52a84514ac
1 changed files with 4 additions and 1 deletions
|
@ -170,6 +170,9 @@ mousestat(Chan *c, uchar *db, int n)
|
|||
static Chan*
|
||||
mouseopen(Chan *c, int omode)
|
||||
{
|
||||
int mode;
|
||||
|
||||
mode = openmode(omode);
|
||||
switch((ulong)c->qid.path){
|
||||
case Qdir:
|
||||
if(omode != OREAD)
|
||||
|
@ -193,7 +196,7 @@ mouseopen(Chan *c, int omode)
|
|||
default:
|
||||
incref(&mouse);
|
||||
}
|
||||
c->mode = openmode(omode);
|
||||
c->mode = mode;
|
||||
c->flag |= COPEN;
|
||||
c->offset = 0;
|
||||
return c;
|
||||
|
|
Loading…
Reference in a new issue