From 75d87cdf3cefd2744fabd3f2a558c49cdf36238b Mon Sep 17 00:00:00 2001 From: Rahul Ruikar Date: Thu, 7 Oct 2010 09:40:45 +0530 Subject: [PATCH] usb: gadget: dummy_hcd: Fix error path In function dummy_udc_probe() call put_device() when device_register() fails. also usb_get_hcd() put before device_register() after review comment from Alan Stern. Signed-off-by: Rahul Ruikar Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/dummy_hcd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index 7bb9d78aac27..1d2a2abbfa80 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c @@ -874,6 +874,8 @@ static int dummy_udc_probe (struct platform_device *pdev) struct dummy *dum = the_controller; int rc; + usb_get_hcd(dummy_to_hcd(dum)); + dum->gadget.name = gadget_name; dum->gadget.ops = &dummy_ops; dum->gadget.is_dualspeed = 1; @@ -885,10 +887,10 @@ static int dummy_udc_probe (struct platform_device *pdev) dum->gadget.dev.parent = &pdev->dev; dum->gadget.dev.release = dummy_gadget_release; rc = device_register (&dum->gadget.dev); - if (rc < 0) + if (rc < 0) { + put_device(&dum->gadget.dev); return rc; - - usb_get_hcd (dummy_to_hcd (dum)); + } platform_set_drvdata (pdev, dum); rc = device_create_file (&dum->gadget.dev, &dev_attr_function);