git: f0a3d2341d34 - stable/13 - sound(4): Fix memory map of /dev/dsp devices when buffer size is not a multiple of PAGE_SIZE.

From: Hans Petter Selasky <hselasky_at_FreeBSD.org>
Date: Sat, 12 Nov 2022 12:41:49 UTC
The branch stable/13 has been updated by hselasky:

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

commit f0a3d2341d345121c92e01f03d439b054f69793c
Author:     Florian Walpen <dev@submerge.ch>
AuthorDate: 2022-11-04 18:04:26 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2022-11-12 12:00:01 +0000

    sound(4): Fix memory map of /dev/dsp devices when buffer size is not a multiple of PAGE_SIZE.
    
    By using sndbuf_getallocsize() instead of sndbuf_getsize() in dsp_mmap_single().
    
    PR:             267555
    Sponsored by:   NVIDIA Networking
    
    (cherry picked from commit ad370f7658ba59811d02c04032ac33ef787f752f)
---
 sys/dev/sound/pcm/dsp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c
index 15f437b8627c..cddc05206c4d 100644
--- a/sys/dev/sound/pcm/dsp.c
+++ b/sys/dev/sound/pcm/dsp.c
@@ -2291,7 +2291,7 @@ dsp_mmap_single(struct cdev *i_dev, vm_ooffset_t *offset,
 
 	c = ((nprot & PROT_WRITE) != 0) ? wrch : rdch;
 	if (c == NULL || (c->flags & CHN_F_MMAP_INVALID) ||
-	    (*offset  + size) > sndbuf_getsize(c->bufsoft) ||
+	    (*offset  + size) > sndbuf_getallocsize(c->bufsoft) ||
 	    (wrch != NULL && (wrch->flags & CHN_F_MMAP_INVALID)) ||
 	    (rdch != NULL && (rdch->flags & CHN_F_MMAP_INVALID))) {
 		relchns(i_dev, rdch, wrch, SD_F_PRIO_RD | SD_F_PRIO_WR);