diff options
author | George Cherian <george.cherian@ti.com> | 2013-05-27 14:35:49 +0530 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2013-06-19 02:16:49 +0100 |
commit | 5b9ce8be3223c6d68e7581b0de59f6a92ccdd02d (patch) | |
tree | fe195462738d60efb9bf044b566f0fcf7f30ca7b | |
parent | 50e293cfbfee3a048ce0f6c04bca8899b20ca353 (diff) | |
download | lwn-5b9ce8be3223c6d68e7581b0de59f6a92ccdd02d.tar.gz lwn-5b9ce8be3223c6d68e7581b0de59f6a92ccdd02d.zip |
usb: dwc3: gadget: free trb pool only from epnum 2
commit 5bf8fae33d14cc5c3c53a926f9079f92c8b082b0 upstream.
we never allocate a TRB pool for physical endpoints
0 and 1 so trying to free it (a invalid TRB pool pointer)
will lead us in a warning while removing dwc3.ko module.
In order to fix the situation, all we have to do is skip
dwc3_free_trb_pool() for physical endpoints 0 and 1 just
as we while deleting endpoints from the endpoints list.
Signed-off-by: George Cherian <george.cherian@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r-- | drivers/usb/dwc3/gadget.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index e9637f991983..b368b83ec7cb 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1310,10 +1310,19 @@ static void dwc3_gadget_free_endpoints(struct dwc3 *dwc) for (epnum = 0; epnum < DWC3_ENDPOINTS_NUM; epnum++) { dep = dwc->eps[epnum]; - dwc3_free_trb_pool(dep); - - if (epnum != 0 && epnum != 1) + /* + * Physical endpoints 0 and 1 are special; they form the + * bi-directional USB endpoint 0. + * + * For those two physical endpoints, we don't allocate a TRB + * pool nor do we add them the endpoints list. Due to that, we + * shouldn't do these two operations otherwise we would end up + * with all sorts of bugs when removing dwc3.ko. + */ + if (epnum != 0 && epnum != 1) { + dwc3_free_trb_pool(dep); list_del(&dep->endpoint.ep_list); + } kfree(dep); } |