usb: gadget: Do not disconnect unregistered dev

configfs_composite_unbind sets the gadget data
to null. Therefore, add check in disconnect
function to make sure that cdev is not NULL.
Prints a WARN message if the driver tries to
redundantly disconnect a gadget.

Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Change-Id: I248cb7175d0dd9a51c18053dd39475d8b3284f6d
This commit is contained in:
Badhri Jagan Sridharan 2015-05-06 13:40:15 -07:00 committed by John Stultz
parent e1cc1e2a37
commit 1c9137c8c5

View file

@ -1870,6 +1870,12 @@ void composite_disconnect(struct usb_gadget *gadget)
struct usb_composite_dev *cdev = get_gadget_data(gadget);
unsigned long flags;
if (cdev == NULL) {
WARN(1, "%s: Calling disconnect on a Gadget that is \
not connected\n", __func__);
return;
}
/* REVISIT: should we have config and device level
* disconnect callbacks?
*/