summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorratchov <ratchov@openbsd.org>2017-11-23 06:26:45 +0000
committerratchov <ratchov@openbsd.org>2017-11-23 06:26:45 +0000
commit8498c5ad2c7522ab1e98a6f4bf20668067735e9f (patch)
treeb6eb45b3e43296d9233437a19703db006c3488ff
parentNo need to grab the audio lock to call audio_canstart() as it checks (diff)
downloadwireguard-openbsd-8498c5ad2c7522ab1e98a6f4bf20668067735e9f.tar.xz
wireguard-openbsd-8498c5ad2c7522ab1e98a6f4bf20668067735e9f.zip
Fix slot leak occuring when the device mode doesn't match
the client mode. Found by landry@.
-rw-r--r--usr.bin/sndiod/dev.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/usr.bin/sndiod/dev.c b/usr.bin/sndiod/dev.c
index 801e36231be..49888085fda 100644
--- a/usr.bin/sndiod/dev.c
+++ b/usr.bin/sndiod/dev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dev.c,v 1.30 2017/11/07 11:41:07 ratchov Exp $ */
+/* $OpenBSD: dev.c,v 1.31 2017/11/23 06:26:45 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
@@ -1514,19 +1514,19 @@ slot_new(struct dev *d, char *who, struct slotops *ops, void *arg, int mode)
found:
if (!dev_ref(d))
return NULL;
- s->dev = d;
- s->ops = ops;
- s->arg = arg;
- s->pstate = SLOT_INIT;
- s->tstate = MMC_OFF;
-
- if ((mode & s->dev->mode) != mode) {
+ if ((mode & d->mode) != mode) {
if (log_level >= 1) {
slot_log(s);
log_puts(": requested mode not supported\n");
}
+ dev_unref(d);
return 0;
}
+ s->dev = d;
+ s->ops = ops;
+ s->arg = arg;
+ s->pstate = SLOT_INIT;
+ s->tstate = MMC_OFF;
s->mode = mode;
aparams_init(&s->par);
if (s->mode & MODE_PLAY) {