From: Rahul Ruikar <rahul.ruikar@gmail.com>
To: David Brownell <dbrownell@users.sourceforge.net>,
Greg Kroah-Hartman <gregkh@suse.de>,
Joe Perches <joe@perches.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Rahul Ruikar <rahul.ruikar@gmail.com>
Subject: [PATCH] usb: gadget: langwell_udc: Fix error path
Date: Sun, 3 Oct 2010 19:19:10 +0530 [thread overview]
Message-ID: <1286113750-2607-1-git-send-email-rahul.ruikar@gmail.com> (raw)
- call device_unregister() only when device_register() is sucess.
- call put_device() when device_register() fails.
Signed-off-by: Rahul Ruikar <rahul.ruikar@gmail.com>
---
drivers/usb/gadget/langwell_udc.c | 18 ++++++++++++++----
drivers/usb/gadget/langwell_udc.h | 4 +++-
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/gadget/langwell_udc.c b/drivers/usb/gadget/langwell_udc.c
index c2d2a20..2b5ae16 100644
--- a/drivers/usb/gadget/langwell_udc.c
+++ b/drivers/usb/gadget/langwell_udc.c
@@ -2952,8 +2952,13 @@ static void langwell_udc_remove(struct pci_dev *pdev)
INFO(dev, "unbind\n");
DBG(dev, "<--- %s()\n", __func__);
- device_unregister(&dev->gadget.dev);
- device_remove_file(&pdev->dev, &dev_attr_langwell_udc);
+ if (dev->dev_reg_status == 2)
+ device_unregister(&dev->gadget.dev);
+ else if (dev->dev_reg_status == 1)
+ put_device(&dev->gadget.dev);
+
+ if (dev->dev_create_file)
+ device_remove_file(&pdev->dev, &dev_attr_langwell_udc);
#ifndef OTG_TRANSCEIVER
pci_set_drvdata(pdev, NULL);
@@ -3190,12 +3195,17 @@ static int langwell_udc_probe(struct pci_dev *pdev,
the_controller = dev;
retval = device_register(&dev->gadget.dev);
- if (retval)
+ if (retval) {
+ dev_reg_status = 1;
goto error;
+ }
+ dev_reg_status = 2;
retval = device_create_file(&pdev->dev, &dev_attr_langwell_udc);
- if (retval)
+ if (retval) {
+ dev_create_file = 1;
goto error;
+ }
VDBG(dev, "<--- %s()\n", __func__);
return 0;
diff --git a/drivers/usb/gadget/langwell_udc.h b/drivers/usb/gadget/langwell_udc.h
index 9719934..cc5d9b6 100644
--- a/drivers/usb/gadget/langwell_udc.h
+++ b/drivers/usb/gadget/langwell_udc.h
@@ -199,7 +199,9 @@ struct langwell_udc {
vbus_active:1,
suspended:1,
stopped:1,
- lpm:1; /* LPM capability */
+ lpm:1, /* LPM capability */
+ dev_reg_status:2,
+ dev_create_file:1;
/* pci state used to access those endpoints */
struct pci_dev *pdev;
--
1.7.2.3
next reply other threads:[~2010-10-03 13:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-03 13:49 Rahul Ruikar [this message]
2010-10-04 10:44 ` Sergei Shtylyov
2010-10-04 10:52 ` Rahul Ruikar
2010-10-05 18:20 Rahul Ruikar
2010-10-05 19:17 ` Sergei Shtylyov
2010-10-06 2:34 ` Rahul Ruikar
2010-10-06 20:21 ` Greg KH
2010-10-07 3:55 ` Rahul Ruikar
2010-10-07 3:52 Rahul Ruikar
2010-10-07 3:54 ` Rahul Ruikar
2010-10-07 17:51 ` Greg KH
2010-10-07 18:19 ` Rahul Ruikar
2010-10-07 20:48 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1286113750-2607-1-git-send-email-rahul.ruikar@gmail.com \
--to=rahul.ruikar@gmail.com \
--cc=dbrownell@users.sourceforge.net \
--cc=gregkh@suse.de \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®