From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>,
Homura Akemi <a1134123566@gmail.com>
Subject: [PATCH v3 04/28] usb: gadget: f_tcm: Fix Get/SetInterface return value
Date: Wed, 11 Dec 2024 00:31:55 +0000 [thread overview]
Message-ID: <ffd91b4640945ea4d3b4f4091cf1abbdbd9cf4fc.1733876548.git.Thinh.Nguyen@synopsys.com> (raw)
In-Reply-To: <cover.1733876548.git.Thinh.Nguyen@synopsys.com>
Check to make sure that the GetInterface and SetInterface are for valid
interface. Return proper alternate setting number on GetInterface.
Fixes: 0b8b1a1fede0 ("usb: gadget: f_tcm: Provide support to get alternate setting in tcm function")
Cc: stable@vger.kernel.org
Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
---
drivers/usb/gadget/function/f_tcm.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c
index 5ce97723376e..f996878e1aea 100644
--- a/drivers/usb/gadget/function/f_tcm.c
+++ b/drivers/usb/gadget/function/f_tcm.c
@@ -2046,9 +2046,14 @@ static void tcm_delayed_set_alt(struct work_struct *wq)
static int tcm_get_alt(struct usb_function *f, unsigned intf)
{
- if (intf == bot_intf_desc.bInterfaceNumber)
+ struct f_uas *fu = to_f_uas(f);
+
+ if (fu->iface != intf)
+ return -EOPNOTSUPP;
+
+ if (fu->flags & USBG_IS_BOT)
return USB_G_ALT_INT_BBB;
- if (intf == uasp_intf_desc.bInterfaceNumber)
+ else if (fu->flags & USBG_IS_UAS)
return USB_G_ALT_INT_UAS;
return -EOPNOTSUPP;
@@ -2058,6 +2063,9 @@ static int tcm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
{
struct f_uas *fu = to_f_uas(f);
+ if (fu->iface != intf)
+ return -EOPNOTSUPP;
+
if ((alt == USB_G_ALT_INT_BBB) || (alt == USB_G_ALT_INT_UAS)) {
struct guas_setup_wq *work;
--
2.28.0
next prev parent reply other threads:[~2024-12-11 1:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-11 0:31 [PATCH v3 00/28] usb: gadget: f_tcm: Enhance UASP driver Thinh Nguyen
2024-12-11 0:31 ` [PATCH v3 01/28] usb: gadget: f_tcm: Don't free command immediately Thinh Nguyen
2024-12-11 0:31 ` [PATCH v3 02/28] usb: gadget: f_tcm: Translate error to sense Thinh Nguyen
2024-12-11 0:31 ` [PATCH v3 03/28] usb: gadget: f_tcm: Decrement command ref count on cleanup Thinh Nguyen
2024-12-11 0:31 ` Thinh Nguyen [this message]
2024-12-11 0:32 ` [PATCH v3 05/28] usb: gadget: f_tcm: ep_autoconfig with fullspeed endpoint Thinh Nguyen
2024-12-11 0:32 ` [PATCH v3 06/28] usb: gadget: f_tcm: Don't prepare BOT write request twice Thinh Nguyen
2024-12-11 10:42 ` [PATCH v3 00/28] usb: gadget: f_tcm: Enhance UASP driver Greg Kroah-Hartman
2024-12-11 17:11 ` Thinh Nguyen
2024-12-20 12:59 ` Homura Akemi
2024-12-20 20:14 ` Thinh Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ffd91b4640945ea4d3b4f4091cf1abbdbd9cf4fc.1733876548.git.Thinh.Nguyen@synopsys.com \
--to=thinh.nguyen@synopsys.com \
--cc=a1134123566@gmail.com \
--cc=bigeasy@linutronix.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox