Skip to contentSkip to conversation

ALSA: rawmidi: Return the error from snd_rawmidi_input_params()

PATCH In review HyeongJun An 2 participants 2 messages Sep 2

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: rawmidi: Return the error from snd_rawmidi_input_params()

The snd_rawmidi_input_params() computes err for the three invalid mode combinations and for resize_runtime_buffer(), applies the new framing and clock type only when err is zero, and then returns 0 anyway. A caller that asked for parameters the kernel rejected is told the change succeeded, and the substream keeps its old buffer.

The open_mutex conversion turned the early returns into assignments. It handled the output sibling correctly, which still returns err, and left this one behind.

Fixes 94b98194b62e ("ALSA: rawmidi: Take open_mutex around parameter changes")
Assisted-by Claude:claude-opus-5

---
Reproduced on 6.17.0-35-generic with snd-virmidi:

  INPUT  buffer_size=0  -> ret  0, errno 0
  INPUT  avail_min=0    -> ret  0, errno 0
  OUTPUT buffer_size=0  -> ret -1, EINVAL

The same rejected parameters report success on the input stream and failure on the output stream.

 sound/core/rawmidi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/rawmidi.c +1 -1
index bf504e27f73e..f9cef3c61861 100644
@@ -782,7 +782,7 @@ int snd_rawmidi_input_params(struct snd_rawmidi_substream *substream,
 		substream->framing = framing;
 		substream->clock_type = clock_type;
 	}
-	return 0;
+	return err;
 }
 EXPORT_SYMBOL(snd_rawmidi_input_params);
 
Signature · 1 line
2.43.0
#1 lore raw
Quoted 7 lines · HyeongJun An

The snd_rawmidi_input_params() computes err for the three invalid mode combinations and for resize_runtime_buffer(), applies the new framing and clock type only when err is zero, and then returns 0 anyway. A caller that asked for parameters the kernel rejected is told the change succeeded, and the substream keeps its old buffer.

Quoted 8 lines

The open_mutex conversion turned the early returns into assignments. It handled the output sibling correctly, which still returns err, and left this one behind.

Fixes 94b98194b62e ("ALSA: rawmidi: Take open_mutex around parameter changes")
Assisted-by Claude:claude-opus-5

Applied now. Thanks.

Takashi