summaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/dummy_hcd.c
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2011-04-15 20:37:06 +0200
committerGreg Kroah-Hartman <gregkh@suse.de>2011-04-30 02:24:36 +0200
commit865835fa441fcabc65251f14280df3055fe82d0f (patch)
tree0460ece61ef14804a0eb67a04425023ef3e2c54c /drivers/usb/gadget/dummy_hcd.c
parentusb/hcd: don't return 0 on error in usb_add_hcd() (diff)
downloadlinux-865835fa441fcabc65251f14280df3055fe82d0f.tar.xz
linux-865835fa441fcabc65251f14280df3055fe82d0f.zip
usb/dummy_hcd: don't probe for udc if hcd failed
the_controller is allocated in dummy_hcd_probe() and is NULL if the allocation failed. The probe function of the udc driver is dereferencing this pointer and fault. Alan Stern suggested to abort the dummy_hcd driver probing so the module is not loaded. The is abort-on-error has been also added to the udc driver. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget/dummy_hcd.c')
-rw-r--r--drivers/usb/gadget/dummy_hcd.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index 3214ca375d64..61ff927928ab 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -892,10 +892,11 @@ static int dummy_udc_probe (struct platform_device *pdev)
return rc;
}
- platform_set_drvdata (pdev, dum);
rc = device_create_file (&dum->gadget.dev, &dev_attr_function);
if (rc < 0)
device_unregister (&dum->gadget.dev);
+ else
+ platform_set_drvdata(pdev, dum);
return rc;
}
@@ -1995,11 +1996,29 @@ static int __init init (void)
retval = platform_device_add(the_hcd_pdev);
if (retval < 0)
goto err_add_hcd;
+ if (!the_controller) {
+ /*
+ * The hcd was added successfully but its probe function failed
+ * for some reason.
+ */
+ retval = -EINVAL;
+ goto err_add_udc;
+ }
retval = platform_device_add(the_udc_pdev);
if (retval < 0)
goto err_add_udc;
+ if (!platform_get_drvdata(the_udc_pdev)) {
+ /*
+ * The udc was added successfully but its probe function failed
+ * for some reason.
+ */
+ retval = -EINVAL;
+ goto err_probe_udc;
+ }
return retval;
+err_probe_udc:
+ platform_device_del(the_udc_pdev);
err_add_udc:
platform_device_del(the_hcd_pdev);
err_add_hcd: