Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c4135060 authored by Tarun Gupta's avatar Tarun Gupta Committed by Vijayavardhan Vennapusa
Browse files

USB: android: release spinlock before queuing work in android_setup



In android_setup we release spinlock after scheduling the work but there
is no need for holding the spinlock during the schedule_work call
is executed this can lead to spinlock timeouts in case where schedule
work takes more time.

So before scheduling work in android_setup we release spinlock to avoid
potential spinlock lockup or timeout.

CRs-Fixed: 586224
Change-Id: Ib7a1105d879292f9d05bc4a9ba50353159048ea3
Signed-off-by: default avatarTarun Gupta <tarung@codeaurora.org>
Signed-off-by: default avatarVijayavardhan Vennapusa <vvreddy@codeaurora.org>
parent ca6129fc
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -3106,6 +3106,7 @@ android_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *c)
	struct android_configuration	*conf;
	int value = -EOPNOTSUPP;
	unsigned long flags;
	bool do_work = false;

	req->zero = 0;
	req->length = 0;
@@ -3135,13 +3136,14 @@ android_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *c)
	spin_lock_irqsave(&cdev->lock, flags);
	if (!dev->connected) {
		dev->connected = 1;
		schedule_work(&dev->work);
		do_work = true;
	} else if (c->bRequest == USB_REQ_SET_CONFIGURATION &&
						cdev->config) {
		schedule_work(&dev->work);
		do_work = true;
	}
	spin_unlock_irqrestore(&cdev->lock, flags);

	if (do_work)
		schedule_work(&dev->work);
	return value;
}