[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1616464217-2650-1-git-send-email-wcheng@codeaurora.org>
Date: Mon, 22 Mar 2021 18:50:17 -0700
From: Wesley Cheng <wcheng@...eaurora.org>
To: balbi@...nel.org, gregkh@...uxfoundation.org
Cc: linux-kernel@...r.kernel.org, linux-usb@...r.kernel.org,
Chandana Kishori Chiluveru <cchiluve@...eaurora.org>,
Wesley Cheng <wcheng@...eaurora.org>
Subject: [PATCH] usb: gadget: Stall OS descriptor request for unsupported functions
From: Chandana Kishori Chiluveru <cchiluve@...eaurora.org>
Hosts which request "OS descriptors" from gadgets do so during
the enumeration phase and before the configuration is set with
SET_CONFIGURATION. Composite driver supports OS descriptor
handling in composite_setup function. This requires to pass
signature field, vendor code, compatibleID and subCompatibleID
from user space.
For USB compositions that contain functions which don't implement os
descriptors, Windows is sending vendor specific requests for os
descriptors and composite driver handling this request with invalid
data. With this invalid info host resetting the bus and never
selecting the configuration and leading enumeration issue.
Fix this by bailing out from the OS descriptor setup request
handling if the functions does not have OS descriptors compatibleID.
Signed-off-by: Chandana Kishori Chiluveru <cchiluve@...eaurora.org>
Signed-off-by: Wesley Cheng <wcheng@...eaurora.org>
---
drivers/usb/gadget/composite.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 72a9797..473edda6 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1945,6 +1945,12 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
buf[6] = w_index;
/* Number of ext compat interfaces */
count = count_ext_compat(os_desc_cfg);
+ /*
+ * Bailout if device does not
+ * have ext_compat interfaces.
+ */
+ if (count == 0)
+ break;
buf[8] = count;
count *= 24; /* 24 B/ext compat desc */
count += 16; /* header */
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
Powered by blists - more mailing lists