Skip to content

Commit

Permalink
ALSA: line6: fix stack overflow in line6_midi_transmit
Browse files Browse the repository at this point in the history
commit b8800d324abb50160560c636bfafe2c81001b66c upstream.

Correctly calculate available space including the size of the chunk
buffer. This fixes a buffer overflow when multiple MIDI sysex
messages are sent to a PODxt device.

Signed-off-by: Artem Egorkine <arteme@gmail.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20221225105728.1153989-2-arteme@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
arteme authored and gregkh committed Jan 18, 2023
1 parent c8b3f17 commit 49cb773
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sound/usb/line6/midi.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ static void line6_midi_transmit(struct snd_rawmidi_substream *substream)
int req, done;

for (;;) {
req = min(line6_midibuf_bytes_free(mb), line6->max_packet_size);
req = min3(line6_midibuf_bytes_free(mb), line6->max_packet_size,
LINE6_FALLBACK_MAXPACKETSIZE);
done = snd_rawmidi_transmit_peek(substream, chunk, req);

if (done == 0)
Expand Down

0 comments on commit 49cb773

Please sign in to comment.