linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: Check for NULL pointer in disconnect
@ 2015-03-20 23:40 Badhri Jagan Sridharan
  2015-03-22  7:43 ` Peter Chen
  0 siblings, 1 reply; 5+ messages in thread
From: Badhri Jagan Sridharan @ 2015-03-20 23:40 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman
  Cc: linux-usb, linux-kernel, Badhri Jagan Sridharan

Added a safety net to make sure that
composite_disconnect does not end up disconneting
a NULL device. Prevents NULL pointer crash.

Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
---
 drivers/usb/gadget/composite.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 13adfd1..90b37bd 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1823,6 +1823,11 @@ void composite_disconnect(struct usb_gadget *gadget)
 	struct usb_composite_dev	*cdev = get_gadget_data(gadget);
 	unsigned long			flags;
 
+	if (!cdev) {
+		WARN(1, "Trying to disconnect a NULL composite device\n");
+		return;
+	}
+
 	/* REVISIT:  should we have config and device level
 	 * disconnect callbacks?
 	 */
-- 
2.2.0.rc0.207.ga3a616c


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-03-24 16:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-20 23:40 [PATCH] usb: gadget: Check for NULL pointer in disconnect Badhri Jagan Sridharan
2015-03-22  7:43 ` Peter Chen
2015-03-23 23:00   ` Badhri Jagan Sridharan
2015-03-24  8:39     ` Peter Chen
2015-03-24 16:30     ` Felipe Balbi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).