Commit 44afcf94 authored by Takashi Iwai's avatar Takashi Iwai Committed by Wen Zhiwei
Browse files

ALSA: seq: Check UMP support for midi_version change

stable inclusion
from stable-v6.6.70
commit 396964d45ca5dc035f5247f90ec800016744661a
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBOHV1

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=396964d45ca5dc035f5247f90ec800016744661a

--------------------------------

commit 8765429279e7d3d68d39ace5f84af2815174bb1e upstream.

When the kernel is built without UMP support but a user-space app
requires the midi_version > 0, the kernel should return an error.
Otherwise user-space assumes as if it were possible to deal,
eventually hitting serious errors later.

Fixes: 46397622 ("ALSA: seq: Add UMP support")
Cc: <stable@vger.kernel.org>
Link: https://patch.msgid.link/20241231145358.21946-1-tiwai@suse.de


Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarWen Zhiwei <wenzhiwei@kylinos.cn>
parent 583f7bc9
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -1280,11 +1280,17 @@ static int snd_seq_ioctl_set_client_info(struct snd_seq_client *client,
	if (client->type != client_info->type)
		return -EINVAL;

	if (client->user_pversion >= SNDRV_PROTOCOL_VERSION(1, 0, 3)) {
		/* check validity of midi_version field */
	if (client->user_pversion >= SNDRV_PROTOCOL_VERSION(1, 0, 3) &&
	    client_info->midi_version > SNDRV_SEQ_CLIENT_UMP_MIDI_2_0)
		if (client_info->midi_version > SNDRV_SEQ_CLIENT_UMP_MIDI_2_0)
			return -EINVAL;

		/* check if UMP is supported in kernel */
		if (!IS_ENABLED(CONFIG_SND_SEQ_UMP) &&
		    client_info->midi_version > 0)
			return -EINVAL;
	}

	/* fill the info fields */
	if (client_info->name[0])
		strscpy(client->name, client_info->name, sizeof(client->name));