The branch stable/11 has been updated by hselasky:

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

commit 6511b6ed285d349f28452b6dbe0d4f46aff47956
Author:     Hans Petter Selasky <[email protected]>
AuthorDate: 2021-11-09 21:07:36 +0000
Commit:     Hans Petter Selasky <[email protected]>
CommitDate: 2021-11-16 08:15:14 +0000

    snd_uaudio(4): Fix string index computations for iFeature.
    
    This allows the iFeature strings to be properly read by the snd_uaudio(4) 
driver,
    when parsing the audio feature unit descriptors.
    
    Submitted by:   [email protected]
    Sponsored by:   NVIDIA Networking
    
    (cherry picked from commit 11f09b17fe2cf0b5489601aee548a06486f0b749)
---
 sys/dev/sound/usb/uaudio.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/sys/dev/sound/usb/uaudio.c b/sys/dev/sound/usb/uaudio.c
index cd6037faaa0d..03356f6c06b3 100644
--- a/sys/dev/sound/usb/uaudio.c
+++ b/sys/dev/sound/usb/uaudio.c
@@ -3664,18 +3664,18 @@ uaudio_mixer_add_feature(struct uaudio_softc *sc,
                cmask |= uaudio_mixer_feature_get_bmaControls(d, chan);
        }
 
-       if (nchan > MIX_MAX_CHAN)
-               nchan = MIX_MAX_CHAN;
-
        MIX(sc).wIndex = MAKE_WORD(d->bUnitId, sc->sc_mixer_iface_no);
 
-       i = d->bmaControls[d->bControlSize];
+       i = d->bmaControls[nchan * d->bControlSize];
        if (i == 0 ||
            usbd_req_get_string_any(sc->sc_udev, NULL,
            MIX(sc).desc, sizeof(MIX(sc).desc), i) != 0) {
                MIX(sc).desc[0] = 0;
        }
 
+       if (nchan > MIX_MAX_CHAN)
+               nchan = MIX_MAX_CHAN;
+
        for (ctl = 1; ctl <= LOUDNESS_CONTROL; ctl++) {
 
                fumask = FU_MASK(ctl);
@@ -3799,9 +3799,6 @@ uaudio20_mixer_add_feature(struct uaudio_softc *sc,
        for (chan = 1; chan < nchan; chan++)
                cmask |= UGETDW(d->bmaControls[chan]);
 
-       if (nchan > MIX_MAX_CHAN)
-               nchan = MIX_MAX_CHAN;
-
        MIX(sc).wIndex = MAKE_WORD(d->bUnitId, sc->sc_mixer_iface_no);
 
        i = d->bmaControls[nchan][0];
@@ -3811,6 +3808,9 @@ uaudio20_mixer_add_feature(struct uaudio_softc *sc,
                MIX(sc).desc[0] = 0;
        }
 
+       if (nchan > MIX_MAX_CHAN)
+               nchan = MIX_MAX_CHAN;
+
        for (ctl = 3; ctl != 0; ctl <<= 2) {
 
                mixernumber = uaudio20_mixer_determine_class(&iot[id]);

Reply via email to