From: ratchov Date: Sat, 1 Jun 2024 09:44:10 +0000 (+0000) Subject: sndiod: Don't add/remove server.device entries in dev_{open,close}() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c7bd5a5d4b7247670d81ed128edab08da5f09a89;p=openbsd sndiod: Don't add/remove server.device entries in dev_{open,close}() Fixes server.device entries disappearing when usb devices are unplugged while in use. Found, analysed and tested by Laurie Tratt, thanks! --- diff --git a/usr.bin/sndiod/dev.c b/usr.bin/sndiod/dev.c index bd2489354f7..47d13152e2f 100644 --- a/usr.bin/sndiod/dev.c +++ b/usr.bin/sndiod/dev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev.c,v 1.116 2024/05/24 15:21:35 ratchov Exp $ */ +/* $OpenBSD: dev.c,v 1.117 2024/06/01 09:44:10 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov * @@ -1054,8 +1054,6 @@ dev_allocbufs(struct dev *d) int dev_open(struct dev *d) { - struct opt *o; - d->mode = d->reqmode; d->round = d->reqround; d->bufsz = d->reqbufsz; @@ -1078,18 +1076,6 @@ dev_open(struct dev *d) return 0; d->pstate = DEV_INIT; - - /* add server.device if device is opened after opt_ref() call */ - for (o = opt_list; o != NULL; o = o->next) { - if (o->refcnt > 0 && !ctl_find(CTL_OPT_DEV, o, d)) { - ctl_new(CTL_OPT_DEV, o, d, - CTL_SEL, dev_getdisplay(d), - o->name, "server", -1, "device", - d->name, -1, 1, o->dev == d); - d->refcnt++; - } - } - return 1; } @@ -1164,14 +1150,6 @@ dev_freebufs(struct dev *d) void dev_close(struct dev *d) { - struct opt *o; - - /* remove server.device entries */ - for (o = opt_list; o != NULL; o = o->next) { - if (ctl_del(CTL_OPT_DEV, o, d)) - d->refcnt--; - } - d->pstate = DEV_CFG; dev_sio_close(d); dev_freebufs(d);