Skip to content

Commit 455be83

Browse files
Thinh Nguyengregkh
authored andcommitted
usb: gadget: f_tcm: Fix Get/SetInterface return value
commit 3b99708 upstream. Check to make sure that the GetInterface and SetInterface are for valid interface. Return proper alternate setting number on GetInterface. Fixes: 0b8b1a1 ("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> Link: https://lore.kernel.org/r/ffd91b4640945ea4d3b4f4091cf1abbdbd9cf4fc.1733876548.git.Thinh.Nguyen@synopsys.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4652446 commit 455be83

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

drivers/usb/gadget/function/f_tcm.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,9 +2051,14 @@ static void tcm_delayed_set_alt(struct work_struct *wq)
20512051

20522052
static int tcm_get_alt(struct usb_function *f, unsigned intf)
20532053
{
2054-
if (intf == bot_intf_desc.bInterfaceNumber)
2054+
struct f_uas *fu = to_f_uas(f);
2055+
2056+
if (fu->iface != intf)
2057+
return -EOPNOTSUPP;
2058+
2059+
if (fu->flags & USBG_IS_BOT)
20552060
return USB_G_ALT_INT_BBB;
2056-
if (intf == uasp_intf_desc.bInterfaceNumber)
2061+
else if (fu->flags & USBG_IS_UAS)
20572062
return USB_G_ALT_INT_UAS;
20582063

20592064
return -EOPNOTSUPP;
@@ -2063,6 +2068,9 @@ static int tcm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
20632068
{
20642069
struct f_uas *fu = to_f_uas(f);
20652070

2071+
if (fu->iface != intf)
2072+
return -EOPNOTSUPP;
2073+
20662074
if ((alt == USB_G_ALT_INT_BBB) || (alt == USB_G_ALT_INT_UAS)) {
20672075
struct guas_setup_wq *work;
20682076

0 commit comments

Comments
 (0)