diff --git a/sndiod/dev.c b/sndiod/dev.c index 9cb7330..4f691e2 100644 --- a/sndiod/dev.c +++ b/sndiod/dev.c @@ -2365,10 +2365,12 @@ dev_rmctl(struct dev *d, int addr) } #endif c->refs_mask &= ~CTL_DEVMASK; - if (c->refs_mask != 0) + if (c->refs_mask == 0) { + *pc = c->next; + xfree(c); return; - *pc = c->next; - xfree(c); + } + c->desc_mask = ~0; } void