From: Takashi Iwai <tiwai@xxxxxxx> commit 228a953e61d6d608a3facc1c3a27b9fb03c99de7 upstream. When the block number 0xff is given to Function Block Discovery message, the device should return the information of all Function Blocks, but currently the gadget driver treats it as an error. Implement the proper behavior for the block 0xff instead. Fixes: 8b645922b223 ("usb: gadget: Add support for USB MIDI 2.0 function driver") Cc: stable@xxxxxxxxxxxxxxx Signed-off-by: Takashi Iwai <tiwai@xxxxxxx> Link: https://lore.kernel.org/r/20240717095102.10493-1-tiwai@xxxxxxx Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/usb/gadget/function/f_midi2.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) --- a/drivers/usb/gadget/function/f_midi2.c +++ b/drivers/usb/gadget/function/f_midi2.c @@ -642,12 +642,21 @@ static void process_ump_stream_msg(struc if (format) return; // invalid blk = (*data >> 8) & 0xff; - if (blk >= ep->num_blks) - return; - if (*data & UMP_STREAM_MSG_REQUEST_FB_INFO) - reply_ump_stream_fb_info(ep, blk); - if (*data & UMP_STREAM_MSG_REQUEST_FB_NAME) - reply_ump_stream_fb_name(ep, blk); + if (blk == 0xff) { + /* inquiry for all blocks */ + for (blk = 0; blk < ep->num_blks; blk++) { + if (*data & UMP_STREAM_MSG_REQUEST_FB_INFO) + reply_ump_stream_fb_info(ep, blk); + if (*data & UMP_STREAM_MSG_REQUEST_FB_NAME) + reply_ump_stream_fb_name(ep, blk); + } + } else if (blk < ep->num_blks) { + /* only the specified block */ + if (*data & UMP_STREAM_MSG_REQUEST_FB_INFO) + reply_ump_stream_fb_info(ep, blk); + if (*data & UMP_STREAM_MSG_REQUEST_FB_NAME) + reply_ump_stream_fb_name(ep, blk); + } return; } } Patches currently in stable-queue which might be from tiwai@xxxxxxx are queue-6.10/alsa-hda-realtek-add-framework-laptop-13-intel-core-ultra-to-quirks.patch queue-6.10/alsa-line6-fix-racy-access-to-midibuf.patch queue-6.10/alsa-hda-add-hp-mp9-g4-retail-system-ams-to-force-connect-list.patch queue-6.10/usb-gadget-midi2-fix-the-response-for-fb-info-with-block-0xff.patch queue-6.10/alsa-usb-audio-re-add-scratchamp-quirk-entries.patch queue-6.10/alsa-hda-hdmi-yet-more-pin-fix-for-hp-elitedesk-800-g4.patch