linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] usb: gadget: composite: fix delayed_status race condition when set_interface
@ 2018-06-22  6:33 Chunfeng Yun
  2018-06-22  6:33 ` [PATCH 2/2] usb: core: phy: fix return value checking about devm_of_phy_get_by_index() Chunfeng Yun
  0 siblings, 1 reply; 6+ messages in thread
From: Chunfeng Yun @ 2018-06-22  6:33 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Felipe Balbi
  Cc: Martin Blumenstingl, Matthias Brugger, Chunfeng Yun, linux-usb,
	devicetree, linux-kernel, linux-arm-kernel, linux-mediatek

It happens when enable debug log, if set_alt() returns
USB_GADGET_DELAYED_STATUS and usb_composite_setup_continue()
is called before increasing count of @delayed_status,
so fix it by using spinlock of @cdev->lock.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Tested-by: Jay Hsu <shih-chieh.hsu@mediatek.com>
---
 drivers/usb/gadget/composite.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index f242c2b..d2fa071 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1719,6 +1719,8 @@ static int fill_ext_prop(struct usb_configuration *c, int interface, u8 *buf)
 		 */
 		if (w_value && !f->get_alt)
 			break;
+
+		spin_lock(&cdev->lock);
 		value = f->set_alt(f, w_index, w_value);
 		if (value == USB_GADGET_DELAYED_STATUS) {
 			DBG(cdev,
@@ -1728,6 +1730,7 @@ static int fill_ext_prop(struct usb_configuration *c, int interface, u8 *buf)
 			DBG(cdev, "delayed_status count %d\n",
 					cdev->delayed_status);
 		}
+		spin_unlock(&cdev->lock);
 		break;
 	case USB_REQ_GET_INTERFACE:
 		if (ctrl->bRequestType != (USB_DIR_IN|USB_RECIP_INTERFACE))
-- 
1.9.1


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

end of thread, other threads:[~2018-06-25 17:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-22  6:33 [PATCH 1/2] usb: gadget: composite: fix delayed_status race condition when set_interface Chunfeng Yun
2018-06-22  6:33 ` [PATCH 2/2] usb: core: phy: fix return value checking about devm_of_phy_get_by_index() Chunfeng Yun
2018-06-24 18:00   ` Martin Blumenstingl
2018-06-25  5:29     ` Johan Hovold
2018-06-25  6:37     ` Chunfeng Yun
2018-06-25 17:32       ` Martin Blumenstingl

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).