diff options
author | anton <anton@cvs.openbsd.org> | 2019-05-22 18:52:15 +0000 |
---|---|---|
committer | anton <anton@cvs.openbsd.org> | 2019-05-22 18:52:15 +0000 |
commit | 3f1dd8d2335d348d20376202ec9ef7098662248e (patch) | |
tree | 83150de3ebaf48c58ed281a512f08e7baf90b000 /sys/dev/wscons/wsmouse.c | |
parent | 0218d2364b8dbd7d1fac92150c117dd08e20c7b6 (diff) |
A wscons device may only be opened in read/write mode once. However,
after checking for exclusive access, malloc() can sleep in
wsevent_init() opening up for a potential race where more than one
thread may be able open the device. Prevent this by checking if the race
was won after calling malloc().
While here, switch to mallocarray as proposed by both cheloha@ and mpi@
ok mpi@
Diffstat (limited to 'sys/dev/wscons/wsmouse.c')
-rw-r--r-- | sys/dev/wscons/wsmouse.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/dev/wscons/wsmouse.c b/sys/dev/wscons/wsmouse.c index 73c304bd53e..57ea83a6aab 100644 --- a/sys/dev/wscons/wsmouse.c +++ b/sys/dev/wscons/wsmouse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsmouse.c,v 1.52 2019/03/24 18:04:02 bru Exp $ */ +/* $OpenBSD: wsmouse.c,v 1.53 2019/05/22 18:52:14 anton Exp $ */ /* $NetBSD: wsmouse.c,v 1.35 2005/02/27 00:27:52 perry Exp $ */ /* @@ -330,7 +330,8 @@ wsmouseopen(dev_t dev, int flags, int mode, struct proc *p) return (EBUSY); evar = &sc->sc_base.me_evar; - wsevent_init(evar); + if (wsevent_init(evar)) + return (EBUSY); error = wsmousedoopen(sc, evar); if (error) { |