From: Yifei Gao <gyf161023@gmail.com>
To: tiwai@suse.com, perex@perex.cz
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
Yifei Gao <gyf161023@gmail.com>
Subject: [PATCH 2/2] ALSA: hdspm: Take hdspm->lock when masking MIDI interrupts in IRQ handler
Date: Fri, 6 Nov 2026 20:50:47 +0000 [thread overview]
Message-ID: <20261106205050.8048-3-gyf161023@gmail.com> (raw)
In-Reply-To: <20261106205050.8048-1-gyf161023@gmail.com>
snd_hdspm_interrupt() clears a MIDI interrupt enable bit in
hdspm->control_register without hdspm->lock. Every other update holds
that lock. This includes snd_hdspm_midi_input_read(), which sets the bit
again, since commit c0da00145f9a ("ALSA: hdspm - Fix locking in
snd_hdspm_midi_input_read"). Updates racing with the handler on another
CPU can be lost. This can stall MIDI input or revert a control setting.
Take hdspm->lock in the handler. All other users of the lock already
run with interrupts disabled.
Found by static analysis. Compile-tested only; no hardware available.
Fixes: 763f356cd8de ("[ALSA] Add HDSP MADI driver")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Yifei Gao <gyf161023@gmail.com>
---
sound/pci/rme9652/hdspm.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index cc4cf43e5a5b..135761278556 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -5383,9 +5383,11 @@ static irqreturn_t snd_hdspm_interrupt(int irq, void *dev_id)
/* we disable interrupts for this input until
* processing is done
*/
- hdspm->control_register &= ~hdspm->midi[i].ie;
- hdspm_write(hdspm, HDSPM_controlRegister,
- hdspm->control_register);
+ scoped_guard(spinlock, &hdspm->lock) {
+ hdspm->control_register &= ~hdspm->midi[i].ie;
+ hdspm_write(hdspm, HDSPM_controlRegister,
+ hdspm->control_register);
+ }
hdspm->midi[i].pending = 1;
schedule = 1;
}
--
2.34.1
prev parent reply other threads:[~2026-11-06 20:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 20:50 [PATCH 0/2] ALSA: hdsp, hdspm: Fix unlocked control_register updates in MIDI paths Yifei Gao
2026-11-06 20:50 ` [PATCH 1/2] ALSA: hdsp: Serialize control_register updates in MIDI input paths Yifei Gao
2026-11-06 20:50 ` Yifei Gao [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261106205050.8048-3-gyf161023@gmail.com \
--to=gyf161023@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®