[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1286135940-2364-1-git-send-email-rahul.ruikar@gmail.com>
Date: Mon, 4 Oct 2010 01:29:00 +0530
From: Rahul Ruikar <rahul.ruikar@...il.com>
To: David Brownell <dbrownell@...rs.sourceforge.net>,
Greg Kroah-Hartman <gregkh@...e.de>,
Dan Carpenter <error27@...il.com>, nm127@...email.hu
Cc: linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
Rahul Ruikar <rahul.ruikar@...il.com>
Subject: [RESEND/PATCH] usb: gadget: goku_udc: Fix error path
call put_device() when device_register() fails.
Signed-off-by: Rahul Ruikar <rahul.ruikar@...il.com>
---
drivers/usb/gadget/goku_udc.c | 12 ++++++++++--
drivers/usb/gadget/goku_udc.h | 3 ++-
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
index 1088d08..bb70125 100644
--- a/drivers/usb/gadget/goku_udc.c
+++ b/drivers/usb/gadget/goku_udc.c
@@ -1744,7 +1744,10 @@ static void goku_remove(struct pci_dev *pdev)
pci_resource_len (pdev, 0));
if (dev->enabled)
pci_disable_device(pdev);
- device_unregister(&dev->gadget.dev);
+ if (dev->reg_status == 2)
+ device_unregister(&dev->gadget.dev);
+ else if (dev->reg_status == 1)
+ put_device(&dev->gadget.dev);
pci_set_drvdata(pdev, NULL);
dev->regs = NULL;
@@ -1847,8 +1850,13 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
/* done */
the_controller = dev;
retval = device_register(&dev->gadget.dev);
- if (retval == 0)
+ if (retval != 0) {
+ dev->reg_status = 2;
+ goto done;
+ } else {
+ dev->reg_status = 1;
return 0;
+ }
done:
if (dev)
diff --git a/drivers/usb/gadget/goku_udc.h b/drivers/usb/gadget/goku_udc.h
index 566cb23..64f2bfb 100644
--- a/drivers/usb/gadget/goku_udc.h
+++ b/drivers/usb/gadget/goku_udc.h
@@ -251,7 +251,8 @@ struct goku_udc {
got_region:1,
req_config:1,
configured:1,
- enabled:1;
+ enabled:1,
+ reg_status:2;
/* pci state used to access those endpoints */
struct pci_dev *pdev;
--
1.7.2.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists