From e0de0a507d83e84c833d01de9e46a44b12419431 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 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 { -- 2.34.1