git: 6716cc7e2768 - stable/14 - sound: Fix memory leak in chn_init()

From: Christos Margiolis <christos_at_FreeBSD.org>
Date: Mon, 29 Jul 2024 15:35:22 UTC
The branch stable/14 has been updated by christos:

URL: https://cgit.FreeBSD.org/src/commit/?id=6716cc7e276816c693647dbfa643fcd110a42f81

commit 6716cc7e276816c693647dbfa643fcd110a42f81
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2024-07-27 11:55:19 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2024-07-29 15:34:54 +0000

    sound: Fix memory leak in chn_init()
    
    In case chn_init() fails, we are leaking memory by not freeing the
    feeder.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      2 days
    Reviewed by:    dev_submerge.ch, markj
    Differential Revision:  https://reviews.freebsd.org/D45979
    
    (cherry picked from commit 16329b7b3276f09dc70bdd1ca8bc605546fe71e0)
---
 sys/dev/sound/pcm/channel.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c
index a18ef1cf4234..19808a43631a 100644
--- a/sys/dev/sound/pcm/channel.c
+++ b/sys/dev/sound/pcm/channel.c
@@ -1365,6 +1365,8 @@ out2:
 	if (CHN_LOCKOWNED(c))
 		CHN_UNLOCK(c);
 	if (ret) {
+		while (chn_removefeeder(c) == 0)
+			;
 		if (c->devinfo) {
 			if (CHANNEL_FREE(c->methods, c->devinfo))
 				sndbuf_free(b);