Skip to content

Commit d683469

Browse files
committed
ALSA: line6: Fix endless MIDI read loop
The MIDI input event parser of the LINE6 driver may enter into an endless loop when the unexpected data sequence is given, as it tries to continue the secondary bytes without termination. Also, when the input data is too short, the parser returns a negative error, while the caller doesn't handle it properly. This would lead to the unexpected behavior as well. This patch addresses those issues by checking the return value correctly and handling the one-byte event in the parser properly. The bug was reported by syzkaller. Reported-by: [email protected] Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent f2ecf90 commit d683469

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

sound/usb/line6/driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ static void line6_data_received(struct urb *urb)
305305
line6_midibuf_read(mb, line6->buffer_message,
306306
LINE6_MIDI_MESSAGE_MAXLEN);
307307

308-
if (done == 0)
308+
if (done <= 0)
309309
break;
310310

311311
line6->message_length = done;

sound/usb/line6/midibuf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ int line6_midibuf_read(struct midi_buffer *this, unsigned char *data,
159159
int midi_length_prev =
160160
midibuf_message_length(this->command_prev);
161161

162-
if (midi_length_prev > 0) {
162+
if (midi_length_prev > 1) {
163163
midi_length = midi_length_prev - 1;
164164
repeat = 1;
165165
} else

0 commit comments

Comments
 (0)