Skip to content

Commit

Permalink
ALSA: usb-audio: Cancel pending work at closing a MIDI substream
Browse files Browse the repository at this point in the history
commit 0125de3 upstream.

At closing a USB MIDI output substream, there might be still a pending
work, which would eventually access the rawmidi runtime object that is
being released.  For fixing the race, make sure to cancel the pending
work at closing.

Reported-by: syzbot+6912c9592caca7ca0e7d@syzkaller.appspotmail.com
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/000000000000e7e75005dfd07cf6@google.com
Link: https://lore.kernel.org/r/20220525131203.11299-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
tiwai authored and gregkh committed Jun 9, 2022
1 parent 1cf70d5 commit 40bdb5e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sound/usb/midi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,9 @@ static int snd_usbmidi_output_open(struct snd_rawmidi_substream *substream)

static int snd_usbmidi_output_close(struct snd_rawmidi_substream *substream)
{
struct usbmidi_out_port *port = substream->runtime->private_data;

cancel_work_sync(&port->ep->work);
return substream_open(substream, 0, 0);
}

Expand Down

0 comments on commit 40bdb5e

Please sign in to comment.