summaryrefslogtreecommitdiff
path: root/usr.bin/sndiod/dev.c
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2020-04-24 11:33:29 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2020-04-24 11:33:29 +0000
commitc557180fe6ebfa7bf9f567c3024bb36bb8b787c7 (patch)
tree1e560758f805df929ba568d6e3785597426474be /usr.bin/sndiod/dev.c
parent31c773afd875d0c9d4705bfaf533697bd928d23f (diff)
Make sure devices are properly closed in case of an error.
Fixes possible crashes if the contol device fails, while the audio device continues to work.
Diffstat (limited to 'usr.bin/sndiod/dev.c')
-rw-r--r--usr.bin/sndiod/dev.c22
1 files changed, 3 insertions, 19 deletions
diff --git a/usr.bin/sndiod/dev.c b/usr.bin/sndiod/dev.c
index 740c8c7b198..9515664107c 100644
--- a/usr.bin/sndiod/dev.c
+++ b/usr.bin/sndiod/dev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dev.c,v 1.70 2020/04/16 12:26:55 ratchov Exp $ */
+/* $OpenBSD: dev.c,v 1.71 2020/04/24 11:33:28 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
@@ -1269,7 +1269,6 @@ int
dev_reopen(struct dev *d)
{
struct slot *s;
- struct ctl *c, **pc;
long long pos;
unsigned int pstate;
int delta;
@@ -1323,23 +1322,8 @@ dev_reopen(struct dev *d)
}
}
- /* remove controls of old device */
- pc = &d->ctl_list;
- while ((c = *pc) != NULL) {
- if (c->addr >= CTLADDR_END) {
- c->refs_mask &= ~CTL_DEVMASK;
- if (c->refs_mask == 0) {
- *pc = c->next;
- xfree(c);
- continue;
- }
- c->type = CTL_NONE;
- c->desc_mask = ~0;
- }
- pc = &c->next;
- }
-
- /* add new device controls */
+ /* remove old controls and add new ones */
+ dev_sioctl_close(d);
dev_sioctl_open(d);
/* start the device if needed */