linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: configfs: Correctly set use_os_string at bind
@ 2025-08-22  3:36 William Wu
  2025-08-22  4:50 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: William Wu @ 2025-08-22  3:36 UTC (permalink / raw)
  To: gregkh
  Cc: linux-usb, linux-kernel, william.wu, frank.wang, jianwei.zheng,
	yue.long

Once the use_os_string flag is set to true for some functions
(e.g. adb/mtp) which need to response the OS string, and then
if we re-bind the ConfigFS gadget to use the other functions
(e.g. hid) which should not to response the OS string, however,
because the use_os_string flag is still true, so the usb gadget
response the OS string descriptor incorrectly, this can cause
the USB device to be unrecognizable on the Windows system.

An example of this as follows:

echo 1 > os_desc/use
ln -s functions/ffs.adb configs/b.1/function0
start adbd
echo "<udc device>" > UDC   #succeed

stop adbd
rm configs/b.1/function0
echo 0 > os_desc/use
ln -s functions/hid.gs0 configs/b.1/function0
echo "<udc device>" > UDC  #fail to connect on Windows

This patch sets the use_os_string flag to false at bind if
the functions not support OS Descriptors.

Signed-off-by: William Wu <william.wu@rock-chips.com>
---
 drivers/usb/gadget/configfs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index f94ea19..6bcac85 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -1750,6 +1750,8 @@ static int configfs_composite_bind(struct usb_gadget *gadget,
 		cdev->use_os_string = true;
 		cdev->b_vendor_code = gi->b_vendor_code;
 		memcpy(cdev->qw_sign, gi->qw_sign, OS_STRING_QW_SIGN_LEN);
+	} else {
+		cdev->use_os_string = false;
 	}
 
 	if (gadget_is_otg(gadget) && !otg_desc[0]) {
-- 
2.0.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: gadget: configfs: Correctly set use_os_string at bind
  2025-08-22  3:36 [PATCH] usb: gadget: configfs: Correctly set use_os_string at bind William Wu
@ 2025-08-22  4:50 ` Greg KH
  2025-08-25  3:12   ` William Wu
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2025-08-22  4:50 UTC (permalink / raw)
  To: William Wu; +Cc: linux-usb, linux-kernel, frank.wang, jianwei.zheng, yue.long

On Fri, Aug 22, 2025 at 11:36:09AM +0800, William Wu wrote:
> Once the use_os_string flag is set to true for some functions
> (e.g. adb/mtp) which need to response the OS string, and then
> if we re-bind the ConfigFS gadget to use the other functions
> (e.g. hid) which should not to response the OS string, however,
> because the use_os_string flag is still true, so the usb gadget
> response the OS string descriptor incorrectly, this can cause
> the USB device to be unrecognizable on the Windows system.
> 
> An example of this as follows:
> 
> echo 1 > os_desc/use
> ln -s functions/ffs.adb configs/b.1/function0
> start adbd
> echo "<udc device>" > UDC   #succeed
> 
> stop adbd
> rm configs/b.1/function0
> echo 0 > os_desc/use
> ln -s functions/hid.gs0 configs/b.1/function0
> echo "<udc device>" > UDC  #fail to connect on Windows
> 
> This patch sets the use_os_string flag to false at bind if
> the functions not support OS Descriptors.
> 
> Signed-off-by: William Wu <william.wu@rock-chips.com>

What commit id does this fix?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: gadget: configfs: Correctly set use_os_string at bind
  2025-08-22  4:50 ` Greg KH
@ 2025-08-25  3:12   ` William Wu
  0 siblings, 0 replies; 3+ messages in thread
From: William Wu @ 2025-08-25  3:12 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-usb, linux-kernel, frank.wang, jianwei.zheng, yue.long



On 8/22/2025 12:50 PM, Greg KH wrote:
> On Fri, Aug 22, 2025 at 11:36:09AM +0800, William Wu wrote:
>> Once the use_os_string flag is set to true for some functions
>> (e.g. adb/mtp) which need to response the OS string, and then
>> if we re-bind the ConfigFS gadget to use the other functions
>> (e.g. hid) which should not to response the OS string, however,
>> because the use_os_string flag is still true, so the usb gadget
>> response the OS string descriptor incorrectly, this can cause
>> the USB device to be unrecognizable on the Windows system.
>>
>> An example of this as follows:
>>
>> echo 1 > os_desc/use
>> ln -s functions/ffs.adb configs/b.1/function0
>> start adbd
>> echo "<udc device>" > UDC   #succeed
>>
>> stop adbd
>> rm configs/b.1/function0
>> echo 0 > os_desc/use
>> ln -s functions/hid.gs0 configs/b.1/function0
>> echo "<udc device>" > UDC  #fail to connect on Windows
>>
>> This patch sets the use_os_string flag to false at bind if
>> the functions not support OS Descriptors.
>>
>> Signed-off-by: William Wu <william.wu@rock-chips.com>
> 
> What commit id does this fix?
Fixes: 87213d388e92 ("usb: gadget: configfs: OS String support")

Best Regards,
William Wu>
> thanks,
> 
> greg k-h
> 
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-08-25  3:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-22  3:36 [PATCH] usb: gadget: configfs: Correctly set use_os_string at bind William Wu
2025-08-22  4:50 ` Greg KH
2025-08-25  3:12   ` William Wu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).