summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2023-11-12 21:49:07 +0000
committercinap_lenrek <cinap_lenrek@felloff.net>2023-11-12 21:49:07 +0000
commit04d6a2acecfe4fe44947da8b676f63bcd0f3c0fe (patch)
treec0aab74517a6dbb8a8111a58c347c76a9f27ff33
parent8e3abc0cce6d52ebf9195ea277a6dbd92ba497a1 (diff)
devuart: fix wrong opens count in case of uartenable() error
-rw-r--r--sys/src/9/port/devuart.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/src/9/port/devuart.c b/sys/src/9/port/devuart.c
index 202151947..81e38b697 100644
--- a/sys/src/9/port/devuart.c
+++ b/sys/src/9/port/devuart.c
@@ -143,10 +143,11 @@ uartmouse(char *which, int (*putc)(Queue*, int), int setb1200)
p = uartport(which);
qlock(p);
- if(p->opens++ == 0 && uartenable(p) == nil){
+ if(p->opens == 0 && uartenable(p) == nil){
qunlock(p);
error(Enodev);
}
+ p->opens++;
if(setb1200)
uartctl(p, "b1200");
p->putc = putc;
@@ -321,11 +322,12 @@ uartopen(Chan *c, int omode)
case Ndataqid:
p = uart[NETID(c->qid.path)];
qlock(p);
- if(p->opens++ == 0 && uartenable(p) == nil){
+ if(p->opens == 0 && uartenable(p) == nil){
qunlock(p);
c->flag &= ~COPEN;
error(Enodev);
}
+ p->opens++;
qunlock(p);
break;
}