git: 364864ea91ab - main - snd_dummy: Round channel pointer after each write

From: Christos Margiolis <christos_at_FreeBSD.org>
Date: Mon, 27 Oct 2025 11:31:05 UTC
The branch main has been updated by christos:

URL: https://cgit.FreeBSD.org/src/commit/?id=364864ea91abbd8a9a79578168fa5d34e05200a7

commit 364864ea91abbd8a9a79578168fa5d34e05200a7
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2025-10-27 11:30:29 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2025-10-27 11:30:29 +0000

    snd_dummy: Round channel pointer after each write
    
    Otherwise we go out of bounds and keep incrementing endlessly.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      4 days
    Differential Revision:  https://reviews.freebsd.org/D53337
---
 sys/dev/sound/dummy.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sys/dev/sound/dummy.c b/sys/dev/sound/dummy.c
index 1f2d69708eec..39214a141bf9 100644
--- a/sys/dev/sound/dummy.c
+++ b/sys/dev/sound/dummy.c
@@ -104,9 +104,10 @@ dummy_chan_io(void *arg)
 		ch = &sc->chans[i];
 		if (!ch->run)
 			continue;
-		if (ch->dir == PCMDIR_PLAY)
+		if (ch->dir == PCMDIR_PLAY) {
 			ch->ptr += sndbuf_getblksz(ch->buf);
-		else
+			ch->ptr %= sndbuf_getsize(ch->buf);
+		} else
 			sndbuf_fillsilence(ch->buf);
 		snd_mtxunlock(sc->lock);
 		chn_intr(ch->chan);