diff options
author | Chandana Kishori Chiluveru <cchiluve@codeaurora.org> | 2016-05-04 13:05:40 +0530 |
---|---|---|
committer | Chandana Kishori Chiluveru <cchiluve@codeaurora.org> | 2016-12-01 18:02:29 +0530 |
commit | ca8e442e9f5b57215474e44bac080f5ac46d5560 (patch) | |
tree | f762079a81b6e63450b6dc57b89959acc9fe347c | |
parent | bde539edca7035e2f1f19c0d93ea02356b38ed48 (diff) |
usb: gadget: composite: Add spinlock protection for usb string descriptor
During composition switch, android driver stops data transfers first
and removes configuration before disabling the pullup. With this sequence
there is a possibility for a race where usb_remove_config is in progress
during which pullup is active and sending the setup request for strings
with zero configuration value. Hence fix the issue by adding spinlock
protection for get_sring descriptor.
Change-Id: I13c601f0e48d847b322a2761cd52268963cacf01
Signed-off-by: Chandana Kishori Chiluveru <cchiluve@codeaurora.org>
-rw-r--r-- | drivers/usb/gadget/composite.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index a480b0a9a238..9360b0613154 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -1670,8 +1670,10 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) value = min(w_length, (u16) value); break; case USB_DT_STRING: + spin_lock(&cdev->lock); value = get_string(cdev, req->buf, w_index, w_value & 0xff); + spin_unlock(&cdev->lock); if (value >= 0) value = min(w_length, (u16) value); break; |