Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH 1/2] ALSA: ump: Don't accept an invalid UMP protocol number
@ 2024-05-29  9:45 Takashi Iwai
  2024-05-29  9:45 ` [PATCH 2/2] ALSA: ump: Set default protocol when not given explicitly Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Takashi Iwai @ 2024-05-29  9:45 UTC (permalink / raw)
  To: linux-sound

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: a79807683781 ("ALSA: ump: Add helper to change MIDI protocol")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/core/ump.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sound/core/ump.c b/sound/core/ump.c
index fd6a68a54278..5bd7b77acb95 100644
--- a/sound/core/ump.c
+++ b/sound/core/ump.c
@@ -685,10 +685,16 @@ static void seq_notify_protocol(struct snd_ump_endpoint *ump)
  */
 int snd_ump_switch_protocol(struct snd_ump_endpoint *ump, unsigned int protocol)
 {
+	unsigned int type;
+
 	protocol &= ump->info.protocol_caps;
 	if (protocol == ump->info.protocol)
 		return 0;
 
+	if (type != SNDRV_UMP_EP_INFO_PROTO_MIDI1 &&
+	    type != SNDRV_UMP_EP_INFO_PROTO_MIDI2)
+		return 0;
+
 	ump->info.protocol = protocol;
 	ump_dbg(ump, "New protocol = %x (caps = %x)\n",
 		protocol, ump->info.protocol_caps);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-05-29  9:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-29  9:45 [PATCH 1/2] ALSA: ump: Don't accept an invalid UMP protocol number Takashi Iwai
2024-05-29  9:45 ` [PATCH 2/2] ALSA: ump: Set default protocol when not given explicitly Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox