aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2011-04-15 14:37:06 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-04-29 20:24:36 -0400
commit865835fa441fcabc65251f14280df3055fe82d0f (patch)
tree0460ece61ef14804a0eb67a04425023ef3e2c54c /drivers/usb/gadget
parent1d15ee4cd7c9ddacfb4b517131b257d8c0d74d42 (diff)
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')
-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)
892 return rc; 892 return rc;
893 } 893 }
894 894
895 platform_set_drvdata (pdev, dum);
896 rc = device_create_file (&dum->gadget.dev, &dev_attr_function); 895 rc = device_create_file (&dum->gadget.dev, &dev_attr_function);
897 if (rc < 0) 896 if (rc < 0)
898 device_unregister (&dum->gadget.dev); 897 device_unregister (&dum->gadget.dev);
898 else
899 platform_set_drvdata(pdev, dum);
899 return rc; 900 return rc;
900} 901}
901 902
@@ -1995,11 +1996,29 @@ static int __init init (void)
1995 retval = platform_device_add(the_hcd_pdev); 1996 retval = platform_device_add(the_hcd_pdev);
1996 if (retval < 0) 1997 if (retval < 0)
1997 goto err_add_hcd; 1998 goto err_add_hcd;
1999 if (!the_controller) {
2000 /*
2001 * The hcd was added successfully but its probe function failed
2002 * for some reason.
2003 */
2004 retval = -EINVAL;
2005 goto err_add_udc;
2006 }
1998 retval = platform_device_add(the_udc_pdev); 2007 retval = platform_device_add(the_udc_pdev);
1999 if (retval < 0) 2008 if (retval < 0)
2000 goto err_add_udc; 2009 goto err_add_udc;
2010 if (!platform_get_drvdata(the_udc_pdev)) {
2011 /*
2012 * The udc was added successfully but its probe function failed
2013 * for some reason.
2014 */
2015 retval = -EINVAL;
2016 goto err_probe_udc;
2017 }
2001 return retval; 2018 return retval;
2002 2019
2020err_probe_udc:
2021 platform_device_del(the_udc_pdev);
2003err_add_udc: 2022err_add_udc:
2004 platform_device_del(the_hcd_pdev); 2023 platform_device_del(the_hcd_pdev);
2005err_add_hcd: 2024err_add_hcd: