Skip to content

Commit 09d2317

Browse files
perexgtiwai
authored andcommitted
ALSA: rawmidi: introduce SNDRV_RAWMIDI_IOCTL_USER_PVERSION
The new framing mode causes the user space regression, because the alsa-lib code does not initialize the reserved space in the params structure when the device is opened. This change adds SNDRV_RAWMIDI_IOCTL_USER_PVERSION like we do for the PCM interface for the protocol acknowledgment. Cc: David Henningsson <coding@diwic.se> Cc: <stable@vger.kernel.org> Fixes: 08fdced ("ALSA: rawmidi: Add framing mode") BugLink: alsa-project/alsa-lib#178 Signed-off-by: Jaroslav Kysela <perex@perex.cz> Link: https://lore.kernel.org/r/20210920171850.154186-1-perex@perex.cz Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent cb1bcf5 commit 09d2317

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

‎include/sound/rawmidi.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ struct snd_rawmidi_file {
9898
struct snd_rawmidi *rmidi;
9999
struct snd_rawmidi_substream *input;
100100
struct snd_rawmidi_substream *output;
101+
unsigned int user_pversion; /* supported protocol version */
101102
};
102103

103104
struct snd_rawmidi_str {

‎include/uapi/sound/asound.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,7 @@ struct snd_rawmidi_status {
784784

785785
#define SNDRV_RAWMIDI_IOCTL_PVERSION _IOR('W', 0x00, int)
786786
#define SNDRV_RAWMIDI_IOCTL_INFO _IOR('W', 0x01, struct snd_rawmidi_info)
787+
#define SNDRV_RAWMIDI_IOCTL_USER_PVERSION _IOW('W', 0x02, int)
787788
#define SNDRV_RAWMIDI_IOCTL_PARAMS _IOWR('W', 0x10, struct snd_rawmidi_params)
788789
#define SNDRV_RAWMIDI_IOCTL_STATUS _IOWR('W', 0x20, struct snd_rawmidi_status)
789790
#define SNDRV_RAWMIDI_IOCTL_DROP _IOW('W', 0x30, int)

‎sound/core/rawmidi.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,12 +873,21 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long
873873
return -EINVAL;
874874
}
875875
}
876+
case SNDRV_RAWMIDI_IOCTL_USER_PVERSION:
877+
if (get_user(rfile->user_pversion, (unsigned int __user *)arg))
878+
return -EFAULT;
879+
return 0;
880+
876881
case SNDRV_RAWMIDI_IOCTL_PARAMS:
877882
{
878883
struct snd_rawmidi_params params;
879884

880885
if (copy_from_user(&params, argp, sizeof(struct snd_rawmidi_params)))
881886
return -EFAULT;
887+
if (rfile->user_pversion < SNDRV_PROTOCOL_VERSION(2, 0, 2)) {
888+
params.mode = 0;
889+
memset(params.reserved, 0, sizeof(params.reserved));
890+
}
882891
switch (params.stream) {
883892
case SNDRV_RAWMIDI_STREAM_OUTPUT:
884893
if (rfile->output == NULL)

0 commit comments

Comments
 (0)