public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: f_midi: fix MIDI Streaming descriptor lengths
@ 2025-01-29 16:05 John Keeping
  2025-01-29 16:40 ` Takashi Iwai
  0 siblings, 1 reply; 7+ messages in thread
From: John Keeping @ 2025-01-29 16:05 UTC (permalink / raw)
  To: linux-usb
  Cc: John Keeping, stable, Greg Kroah-Hartman, Kees Cook, Abdul Rahim,
	Michael Grzeschik, Jeff Johnson, Felipe Balbi, Daniel Mack,
	linux-kernel

In the two loops before setting the MIDIStreaming descriptors,
ms_in_desc.baAssocJackID[] has entries written for "in_ports" values and
ms_out_desc.baAssocJackID[] has entries written for "out_ports" values.
But the counts and lengths are set the other way round in the
descriptors.

Fix the descriptors so that the bNumEmbMIDIJack values and the
descriptor lengths match the number of entries populated in the trailing
arrays.

Cc: stable@vger.kernel.org
Fixes: c8933c3f79568 ("USB: gadget: f_midi: allow a dynamic number of input and output ports")
Signed-off-by: John Keeping <jkeeping@inmusicbrands.com>
---
 drivers/usb/gadget/function/f_midi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/function/f_midi.c
index 837fcdfa3840f..6cc3d86cb4774 100644
--- a/drivers/usb/gadget/function/f_midi.c
+++ b/drivers/usb/gadget/function/f_midi.c
@@ -1000,11 +1000,11 @@ static int f_midi_bind(struct usb_configuration *c, struct usb_function *f)
 	}
 
 	/* configure the endpoint descriptors ... */
-	ms_out_desc.bLength = USB_DT_MS_ENDPOINT_SIZE(midi->in_ports);
-	ms_out_desc.bNumEmbMIDIJack = midi->in_ports;
+	ms_out_desc.bLength = USB_DT_MS_ENDPOINT_SIZE(midi->out_ports);
+	ms_out_desc.bNumEmbMIDIJack = midi->out_ports;
 
-	ms_in_desc.bLength = USB_DT_MS_ENDPOINT_SIZE(midi->out_ports);
-	ms_in_desc.bNumEmbMIDIJack = midi->out_ports;
+	ms_in_desc.bLength = USB_DT_MS_ENDPOINT_SIZE(midi->in_ports);
+	ms_in_desc.bNumEmbMIDIJack = midi->in_ports;
 
 	/* ... and add them to the list */
 	endpoint_descriptor_index = i;
-- 
2.48.1


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

end of thread, other threads:[~2025-01-30 17:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-29 16:05 [PATCH] usb: gadget: f_midi: fix MIDI Streaming descriptor lengths John Keeping
2025-01-29 16:40 ` Takashi Iwai
2025-01-29 17:31   ` John Keeping
2025-01-30 10:50     ` Takashi Iwai
2025-01-30 10:59       ` John Keeping
2025-01-30 12:17         ` Takashi Iwai
2025-01-30 17:10           ` John Keeping

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