[PATCH] ALSA: sis7019: Don't shift the voice IRQ status by 32

From: Suyuan Wang via B4 Relay

Date: Sun Nov 22 2026 - 05:08:21 EST


From: Suyuan Wang <stevewong@xxxxxxxxxxx>

sis_voice_irq() walks the set bits of a PISR_A or PISR_B status word:

bit = __ffs(status);
status >>= bit + 1;

When voice 31 or 63 interrupts, bit is 31 and status is shifted by 32,
which is undefined for a u32. On x86 the shift count is masked to 0, so
status does not change, the loop never ends, and voice keeps moving 32
entries forward on every pass, past the end of sis->voices[], with
sis_update_voice() called on whatever is there. All of this runs in the
hard IRQ handler. Voices are handed out from 0 up, so voice 31 is in use
once enough playback streams are open.

Walk the bits with for_each_set_bit() and index the voice by bit number
instead. The voices are still updated in the same order.

Found with a static analysis tool and checked by hand.

Fixes: 175859bf1602 ("[ALSA] sis7019: support the SiS 7019 Audio Accelerator")
Cc: stable@xxxxxxxxxxxxxxx
Co-developed-by: Kaixuan Li <kaixuan.li@xxxxxxxxxx>
Signed-off-by: Kaixuan Li <kaixuan.li@xxxxxxxxxx>
Signed-off-by: Suyuan Wang <stevewong@xxxxxxxxxxx>
---
Compile tested (i386, W=1). I don't have a SiS 7019, so I ran the old
and new loop in userspace on the same status words: with 0x80000000 the
old loop trips UBSan's shift check, and without it ASan reports a read
past the 64-entry voice array; the new loop updates voice 31 (or 63)
and stops.
---
sound/pci/sis7019.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c
index fe5bda5af6a5..f31e62068ee3 100644
--- a/sound/pci/sis7019.c
+++ b/sound/pci/sis7019.c
@@ -278,15 +278,11 @@ static void sis_update_voice(struct voice *voice)

static void sis_voice_irq(u32 status, struct voice *voice)
{
+ unsigned long bits = status;
int bit;

- while (status) {
- bit = __ffs(status);
- status >>= bit + 1;
- voice += bit;
- sis_update_voice(voice);
- voice++;
- }
+ for_each_set_bit(bit, &bits, 32)
+ sis_update_voice(&voice[bit]);
}

static irqreturn_t sis_interrupt(int irq, void *dev)