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:
cinap_lenrek 2013-08-27 23:26:30 +02:00
parent 244d2ee84b
commit 52a84514ac

View file

@ -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;