From: Benoit Goby Date: Tue, 29 Nov 2011 21:49:27 +0000 (-0800) Subject: usb: gadget: android: Cancel pending ctrlrequest before disabling X-Git-Tag: firefly_0821_release~7613^2~214 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e0de0a507d83e84c833d01de9e46a44b12419431;p=firefly-linux-kernel-4.4.55.git usb: gadget: android: Cancel pending ctrlrequest before disabling Make sure there is no pending ctrlrequest before removing the config. Otherwise the ctrlrequest complete callback could access structures after they have been freed. Unbind cancels pending transfers but not ep0 requests. Bug: 5513065 5440193 Change-Id: I063c22bf5d104a3d2df71cf622409459fac5f27a Signed-off-by: Benoit Goby --- diff --git a/drivers/usb/gadget/android.c b/drivers/usb/gadget/android.c index 5d77899678f9..2b7631052ea7 100644 --- a/drivers/usb/gadget/android.c +++ b/drivers/usb/gadget/android.c @@ -837,6 +837,8 @@ static ssize_t enable_store(struct device *pdev, struct device_attribute *attr, dev->enabled = true; } else if (!enabled && dev->enabled) { usb_gadget_disconnect(cdev->gadget); + /* Cancel pending control requests */ + usb_ep_dequeue(cdev->gadget->ep0, cdev->req); usb_remove_config(cdev, &android_config_driver); dev->enabled = false; } else {