Skip to content

Commit ac0d71e

Browse files
committed
ALSA: ump: Don't accept an invalid UMP protocol number
When a UMP Stream Configuration message is received, the driver tries to switch the protocol, but there was no sanity check of the protocol, hence it can pass an invalid value. Add the check and bail out if a wrong value is passed. Fixes: a798076 ("ALSA: ump: Add helper to change MIDI protocol") Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 6d40dbc commit ac0d71e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

sound/core/ump.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,10 +685,17 @@ static void seq_notify_protocol(struct snd_ump_endpoint *ump)
685685
*/
686686
int snd_ump_switch_protocol(struct snd_ump_endpoint *ump, unsigned int protocol)
687687
{
688+
unsigned int type;
689+
688690
protocol &= ump->info.protocol_caps;
689691
if (protocol == ump->info.protocol)
690692
return 0;
691693

694+
type = protocol & SNDRV_UMP_EP_INFO_PROTO_MIDI_MASK;
695+
if (type != SNDRV_UMP_EP_INFO_PROTO_MIDI1 &&
696+
type != SNDRV_UMP_EP_INFO_PROTO_MIDI2)
697+
return 0;
698+
692699
ump->info.protocol = protocol;
693700
ump_dbg(ump, "New protocol = %x (caps = %x)\n",
694701
protocol, ump->info.protocol_caps);

0 commit comments

Comments
 (0)