From: Dima Zavin Date: Wed, 14 Sep 2011 18:53:11 +0000 (-0700) Subject: usb: gadget: android: follow proper order on disconnect X-Git-Tag: firefly_0821_release~7613^2~311 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=21bad758ae85ca6043d55ed7877946e94d6cc1c7;p=firefly-linux-kernel-4.4.55.git usb: gadget: android: follow proper order on disconnect We should composite_disconnect *before* updating our internal state and sending uevent to userspace. Also, hold cdev->lock while updating internal state. Change-Id: If66a5a4f7d4a102a44aefc3ce4a154a5a1517dcf Signed-off-by: Dima Zavin --- diff --git a/drivers/usb/gadget/android.c b/drivers/usb/gadget/android.c index b7e402921c65..a7d5b19dc161 100644 --- a/drivers/usb/gadget/android.c +++ b/drivers/usb/gadget/android.c @@ -1081,9 +1081,15 @@ android_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *c) static void android_disconnect(struct usb_gadget *gadget) { struct android_dev *dev = _android_dev; + struct usb_composite_dev *cdev = get_gadget_data(gadget); + unsigned long flags; + + composite_disconnect(gadget); + + spin_lock_irqsave(&cdev->lock, flags); dev->connected = 0; schedule_work(&dev->work); - composite_disconnect(gadget); + spin_unlock_irqrestore(&cdev->lock, flags); } static int android_create_device(struct android_dev *dev)