From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA2DA17A2E8; Mon, 10 Mar 2025 18:00:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741629646; cv=none; b=ZOhwYBVDlX46KdWiV2VbAcmW1sIiJALVeQXnRduMtPyb3+cdJeFLXlvpRri1acwddLw45qxOBdWdC/xI6nPl7DzMsdaVDoeTffYlPzwu/4Tvrwwnme+7YpS2GPCHVeEMiRe5c1dPZafdfQ8upkzpAjRyD1H6m/OOPDZb3SyneGM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741629646; c=relaxed/simple; bh=mcZCSoDSluwZVURjx8ioWcBqLnAuyAwziGQ7VQ7dxWM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RbnSOCnCemzyN2v86OvGdx46mpE0GiNlE8cQbWQAizYb/TPFi8F4HzwL6OWMmncrCE34kieofqdWLaLrVJhUh+u0XXAxFDYEwMd3nAbK4r3oW+5P+2Sntp57trwwbpICOuzGVHP0JJUrPMWZ50Mei45MZ437E+rGZmxFEbsCRKI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=2ssXC9rt; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="2ssXC9rt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32208C4CEE5; Mon, 10 Mar 2025 18:00:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1741629646; bh=mcZCSoDSluwZVURjx8ioWcBqLnAuyAwziGQ7VQ7dxWM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2ssXC9rtftLe8EYYda/vj+J2aiIoenNNJcnMGqDVu5bML2KkfP20qnriVZ9poGZUF gzx0CRgiFEcu/UQw5FBrcEpLpKghKzATfpmReNrZ1xAJPr0CfZXFEO3etof12w09EQ Aw/xHsURoEzzQY8KkoJvTSqmOfozNW3h+3/rvb6s= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , John Keeping , Takashi Iwai Subject: [PATCH 5.15 367/620] usb: gadget: f_midi: fix MIDI Streaming descriptor lengths Date: Mon, 10 Mar 2025 18:03:33 +0100 Message-ID: <20250310170600.091768848@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250310170545.553361750@linuxfoundation.org> References: <20250310170545.553361750@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: John Keeping commit da1668997052ed1cb00322e1f3b63702615c9429 upstream. While the MIDI jacks are configured correctly, and the MIDIStreaming endpoint descriptors are filled with the correct information, bNumEmbMIDIJack and bLength are set incorrectly in these descriptors. This does not matter when the numbers of in and out ports are equal, but when they differ the host will receive broken descriptors with uninitialized stack memory leaking into the descriptor for whichever value is smaller. The precise meaning of "in" and "out" in the port counts is not clearly defined and can be confusing. But elsewhere the driver consistently uses this to match the USB meaning of IN and OUT viewed from the host, so that "in" ports send data to the host and "out" ports receive data from it. Cc: stable Fixes: c8933c3f79568 ("USB: gadget: f_midi: allow a dynamic number of input and output ports") Signed-off-by: John Keeping Reviewed-by: Takashi Iwai Link: https://lore.kernel.org/r/20250130195035.3883857-1-jkeeping@inmusicbrands.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/f_midi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/usb/gadget/function/f_midi.c +++ b/drivers/usb/gadget/function/f_midi.c @@ -999,11 +999,11 @@ static int f_midi_bind(struct usb_config } /* 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;