All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: f_serial: Ensure gserial disconnected during unbind
@ 2022-01-11  6:48 Wesley Cheng
  0 siblings, 0 replies; only message in thread
From: Wesley Cheng @ 2022-01-11  6:48 UTC (permalink / raw)
  To: balbi, gregkh; +Cc: linux-usb, linux-kernel, quic_jackp, Wesley Cheng

Some UDCs may return an error during pullup disable as part of the
unbind path for a USB configuration.  This will lead to a scenario
where the disable() callback is skipped, whereas the unbind() still
occurs.  If this happens, the u_serial driver will continue to fail
subsequent binds, due to an already existing entry in the ports array.
Ensure that gserial_disconnect() is called during the f_serial unbind,
so the ports entry is properly cleared.

Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
---
 drivers/usb/gadget/function/f_serial.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/gadget/function/f_serial.c b/drivers/usb/gadget/function/f_serial.c
index 1ed8ff0ac2d3..a9480b9e312e 100644
--- a/drivers/usb/gadget/function/f_serial.c
+++ b/drivers/usb/gadget/function/f_serial.c
@@ -345,6 +345,10 @@ static void gser_free(struct usb_function *f)
 
 static void gser_unbind(struct usb_configuration *c, struct usb_function *f)
 {
+	struct f_gser	*gser = func_to_gser(f);
+
+	/* Ensure port is disconnected before unbinding */
+	gserial_disconnect(&gser->port);
 	usb_free_all_descriptors(f);
 }
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-01-11  6:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-11  6:48 [PATCH] usb: gadget: f_serial: Ensure gserial disconnected during unbind Wesley Cheng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.