usb: gadget: udc-core: fix a regression during gadget driver unbinding
authorAlan Stern <stern@rowland.harvard.edu>
Fri, 15 Mar 2013 18:02:14 +0000 (14:02 -0400)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 27 Mar 2013 02:41:19 +0000 (02:41 +0000)
commit0d631c8470f3e868e9f024e4b69fa834a7594937
tree5e1473f611ec4aeaff45cb3b5947beb6326002e7
parent9333d5f483413b822798b77f32d2473ad454a059
usb: gadget: udc-core: fix a regression during gadget driver unbinding

commit 511f3c5326eabe1ece35202a404c24c0aeacc246 upstream.

This patch (as1666) fixes a regression in the UDC core.  The core
takes care of unbinding gadget drivers, and it does the unbinding
before telling the UDC driver to turn off the controller hardware.
When the call to the udc_stop callback is made, the gadget no longer
has a driver.  The callback routine should not be invoked with a
pointer to the old driver; doing so can cause problems (such as
use-after-free accesses in net2280).

This patch should be applied, with appropriate context changes, to all
the stable kernels going back to 3.1.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Felipe Balbi <balbi@ti.com>
[bwh: Backported to 3.2: adjust context, indentation]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/usb/gadget/udc-core.c