diff options
author | Chunfeng Yun <chunfeng.yun@mediatek.com> | 2018-05-25 05:24:57 -0400 |
---|---|---|
committer | Felipe Balbi <felipe.balbi@linux.intel.com> | 2018-06-19 05:48:13 -0400 |
commit | 980900d6318066b9f8314bfb87329a20fd0d1ca4 (patch) | |
tree | 46c4f425c8c91c48001af3f6447ae8d87b54512c /drivers/usb | |
parent | 70c3c8cb83856758025c2a211dd022bc0478922a (diff) |
usb: gadget: composite: fix delayed_status race condition when set_interface
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>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/gadget/composite.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index f242c2bcea81..d2fa071c21b1 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c | |||
@@ -1719,6 +1719,8 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) | |||
1719 | */ | 1719 | */ |
1720 | if (w_value && !f->get_alt) | 1720 | if (w_value && !f->get_alt) |
1721 | break; | 1721 | break; |
1722 | |||
1723 | spin_lock(&cdev->lock); | ||
1722 | value = f->set_alt(f, w_index, w_value); | 1724 | value = f->set_alt(f, w_index, w_value); |
1723 | if (value == USB_GADGET_DELAYED_STATUS) { | 1725 | if (value == USB_GADGET_DELAYED_STATUS) { |
1724 | DBG(cdev, | 1726 | DBG(cdev, |
@@ -1728,6 +1730,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) | |||
1728 | DBG(cdev, "delayed_status count %d\n", | 1730 | DBG(cdev, "delayed_status count %d\n", |
1729 | cdev->delayed_status); | 1731 | cdev->delayed_status); |
1730 | } | 1732 | } |
1733 | spin_unlock(&cdev->lock); | ||
1731 | break; | 1734 | break; |
1732 | case USB_REQ_GET_INTERFACE: | 1735 | case USB_REQ_GET_INTERFACE: |
1733 | if (ctrl->bRequestType != (USB_DIR_IN|USB_RECIP_INTERFACE)) | 1736 | if (ctrl->bRequestType != (USB_DIR_IN|USB_RECIP_INTERFACE)) |