From 03af99cfe3f3379995b3c18576e9bb97d054e250 Mon Sep 17 00:00:00 2001 From: Benoit Goby Date: Tue, 29 Nov 2011 13:49:27 -0800 Subject: [PATCH] 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 --- drivers/usb/gadget/android.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/gadget/android.c b/drivers/usb/gadget/android.c index eda640e70623..78ada00febe3 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 { -- 2.34.1