Skip to content

Commit

Permalink
ALSA: usb-audio: Drop snd_BUG_ON() from snd_usbmidi_output_open()
Browse files Browse the repository at this point in the history
snd_usbmidi_output_open() has a check of the NULL port with
snd_BUG_ON().  snd_BUG_ON() was used as this shouldn't have happened,
but in reality, the NULL port may be seen when the device gives an
invalid endpoint setup at the descriptor, hence the driver skips the
allocation.  That is, the check itself is valid and snd_BUG_ON()
should be dropped from there.  Otherwise it's confusing as if it were
a real bug, as recently syzbot stumbled on it.

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]>
  • Loading branch information
tiwai committed Nov 12, 2022
1 parent 5534bbb commit ad72c3c
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions sound/usb/midi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1133,10 +1133,8 @@ static int snd_usbmidi_output_open(struct snd_rawmidi_substream *substream)
port = &umidi->endpoints[i].out->ports[j];
break;
}
if (!port) {
snd_BUG();
if (!port)
return -ENXIO;
}

substream->runtime->private_data = port;
port->state = STATE_UNKNOWN;
Expand Down

0 comments on commit ad72c3c

Please sign in to comment.