Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit 6cc4e5e

Browse files
tiwaigregkh
authored andcommitted
ALSA: hdsp: Break infinite MIDI input flush loop
[ Upstream commit c01f381 ] The current MIDI input flush on HDSP and HDSPM drivers relies on the hardware reporting the right value. If the hardware doesn't give the proper value but returns -1, it may be stuck at an infinite loop. Add a counter and break if the loop is unexpectedly too long. Link: https://patch.msgid.link/20240808091513.31380-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 7a55740 commit 6cc4e5e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

sound/pci/rme9652/hdsp.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -1298,8 +1298,10 @@ static int snd_hdsp_midi_output_possible (struct hdsp *hdsp, int id)
12981298

12991299
static void snd_hdsp_flush_midi_input (struct hdsp *hdsp, int id)
13001300
{
1301-
while (snd_hdsp_midi_input_available (hdsp, id))
1302-
snd_hdsp_midi_read_byte (hdsp, id);
1301+
int count = 256;
1302+
1303+
while (snd_hdsp_midi_input_available(hdsp, id) && --count)
1304+
snd_hdsp_midi_read_byte(hdsp, id);
13031305
}
13041306

13051307
static int snd_hdsp_midi_output_write (struct hdsp_midi *hmidi)

sound/pci/rme9652/hdspm.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -1838,8 +1838,10 @@ static inline int snd_hdspm_midi_output_possible (struct hdspm *hdspm, int id)
18381838

18391839
static void snd_hdspm_flush_midi_input(struct hdspm *hdspm, int id)
18401840
{
1841-
while (snd_hdspm_midi_input_available (hdspm, id))
1842-
snd_hdspm_midi_read_byte (hdspm, id);
1841+
int count = 256;
1842+
1843+
while (snd_hdspm_midi_input_available(hdspm, id) && --count)
1844+
snd_hdspm_midi_read_byte(hdspm, id);
18431845
}
18441846

18451847
static int snd_hdspm_midi_output_write (struct hdspm_midi *hmidi)

0 commit comments

Comments
 (0)