git: 8233ccc3bcee - stable/14 - sound: Do not fail from vchan_destroy() if children list is empty

From: Christos Margiolis <christos_at_FreeBSD.org>
Date: Tue, 04 Mar 2025 15:46:54 UTC
The branch stable/14 has been updated by christos:

URL: https://cgit.FreeBSD.org/src/commit/?id=8233ccc3bcee6dbe6179eca605d8a354a861cf7e

commit 8233ccc3bcee6dbe6179eca605d8a354a861cf7e
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2025-02-25 11:43:11 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2025-03-04 15:46:05 +0000

    sound: Do not fail from vchan_destroy() if children list is empty
    
    vchan_destroy() should be able to call chn_kill() regardless of whether
    the channel has been added to the children list yet or not. Also remove
    the CHN_F_BUSY check. There is no reason we shouldn't execute the code
    below if the parent is not busy.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Reviewed by:    dev_submerge.ch
    Differential Revision:  https://reviews.freebsd.org/D48185
    
    (cherry picked from commit 405b1e50926d4162fb9503644073c0184a8b37d9)
---
 sys/dev/sound/pcm/vchan.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/sys/dev/sound/pcm/vchan.c b/sys/dev/sound/pcm/vchan.c
index 4165d0712b94..ea8a50b316fe 100644
--- a/sys/dev/sound/pcm/vchan.c
+++ b/sys/dev/sound/pcm/vchan.c
@@ -838,15 +838,8 @@ vchan_destroy(struct pcm_channel *c)
 
 	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);