diff --git a/sys/dev/sound/pcm/vchan.c b/sys/dev/sound/pcm/vchan.c --- a/sys/dev/sound/pcm/vchan.c +++ b/sys/dev/sound/pcm/vchan.c @@ -838,18 +838,13 @@ CHN_UNLOCK(c); - if (!(parent->flags & CHN_F_BUSY)) - return (EBUSY); - - if (CHN_EMPTY(parent, children)) - return (EINVAL); - - /* remove us from our parent's children list */ - CHN_REMOVE(parent, c, children); - - if (CHN_EMPTY(parent, children)) { - parent->flags &= ~(CHN_F_BUSY | CHN_F_HAS_VCHAN); - chn_reset(parent, parent->format, parent->speed); + if (!CHN_EMPTY(parent, children)) { + /* remove us from our parent's children list */ + CHN_REMOVE_SAFE(parent, c, children); + if (CHN_EMPTY(parent, children)) { + parent->flags &= ~(CHN_F_BUSY | CHN_F_HAS_VCHAN); + chn_reset(parent, parent->format, parent->speed); + } } CHN_UNLOCK(parent);