summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-08-27 23:26:30 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2013-08-27 23:26:30 +0200
commit52a84514acca8c2afc7e33c6f3f7d95235cad75e (patch)
treeed426986a405b0ae0487976c7ddcc9442dcb0fc5
parent244d2ee84b1367ee7eb60395f75a5cb9bc5616a6 (diff)
downloadplan9front-52a84514acca8c2afc7e33c6f3f7d95235cad75e.tar.xz
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.
-rw-r--r--sys/src/9/port/devmouse.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/src/9/port/devmouse.c b/sys/src/9/port/devmouse.c
index c16ed0b60..2f8ffe6e2 100644
--- a/sys/src/9/port/devmouse.c
+++ b/sys/src/9/port/devmouse.c
@@ -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;