From 7f05db38f3f2b483fccba60812fbd0474be85b7a Mon Sep 17 00:00:00 2001 From: Gary King Date: Mon, 7 Dec 2009 21:09:05 -0800 Subject: gadget: check for NULL before dereferencing cdev->config don't attempt to dereference a function before it has been registered --- drivers/usb/gadget/composite.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 6995a10a608a..185385b185df 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -779,7 +779,9 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) goto unknown; if (!cdev->config || w_index >= MAX_CONFIG_INTERFACES) break; - f = cdev->config->interface[intf]; + f = NULL; + if (cdev->config) + f = cdev->config->interface[intf]; if (!f) break; if (w_value && !f->set_alt) -- cgit v1.2.3