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

Commit 0afc9f1c authored by ChandanaKishori Chiluveru's avatar ChandanaKishori Chiluveru Committed by Matt Wagantall
Browse files

usb: android: Skip the work when set_config arrives with same value twice



Some USB hosts may send SET_CONFIGURATION with same value twice.
The current code implementation processing the 2nd set_config and
schedules the work. The android_work() issues disconnect event to
userspace if SetConfiguration with non-zero value is sent twice.
The userspace applications may disconnect the USB and the device
doesn't connect to the host.

Fix this by avoiding the android_work for the second time SET_CONFIGURATION
request when it receives SetConfiguration request with same configuration
value twice from the host.

CRs-Fixed: 661220
Change-Id: Ic450315a9067b9b679b4936480d125e4e4b7cdf7
Signed-off-by: default avatarChandanaKishori Chiluveru <cchilu@codeaurora.org>
parent 1bf16ed5
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -3502,6 +3502,7 @@ android_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *c)
	int value = -EOPNOTSUPP;
	unsigned long flags;
	bool do_work = false;
	bool prev_configured = false;

	req->zero = 0;
	req->length = 0;
@@ -3520,6 +3521,12 @@ android_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *c)
			}
		}

	/*
	 * skip the  work when 2nd set config arrives
	 * with same value from the host.
	 */
	if (cdev->config)
		prev_configured = true;
	/* Special case the accessory function.
	 * It needs to handle control requests before it is enabled.
	 */
@@ -3536,6 +3543,7 @@ android_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *c)
		schedule_work(&dev->work);
	} else if (c->bRequest == USB_REQ_SET_CONFIGURATION &&
						cdev->config) {
		if (!prev_configured)
			do_work = true;
	}
	spin_unlock_irqrestore(&cdev->lock, flags);