From: Badhri Jagan Sridharan Date: Wed, 6 May 2015 20:40:15 +0000 (-0700) Subject: usb: gadget: Do not disconnect unregistered dev X-Git-Tag: firefly_0821_release~2958^2~359 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=1c9137c8c53cf4af32f33ac1d8d2c9675009991b;p=firefly-linux-kernel-4.4.55.git 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 Change-Id: I248cb7175d0dd9a51c18053dd39475d8b3284f6d --- diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 8b14c2a13ac5..ffa2a682c04b 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -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? */