From: Francois Romieu <romieu@fr.zoreil.com>
To: chas williams <chas@locutus.cmf.nrl.navy.mil>
Cc: davem@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [ATM] [PATCH] unbalanced exit path in Forerunner HE he_init_one()
Date: Thu, 8 May 2003 15:18:40 +0200 [thread overview]
Message-ID: <20030508151840.C26472@electric-eye.fr.zoreil.com> (raw)
In-Reply-To: <200305081220.h48CK9Gi002815@locutus.cmf.nrl.navy.mil>; from chas@locutus.cmf.nrl.navy.mil on Thu, May 08, 2003 at 08:20:09AM -0400
chas williams <chas@locutus.cmf.nrl.navy.mil> :
[...]
> actually pci_disable_device() should probably go into he_stop() or
> add it to he_remove_one() and he_cleanup()
Doh... This should be more accurate:
- pci_enable_device() balanced on error path in he_init_one();
- return of atm_dev_register() isn't lost any more if he_dev allocation fails
in he_init_one();
- pci_disable_device() added to he_disable_one();
- he_cleanup() calls he_disable_one() instead of duplicating it;
- partial rework of code dedicated to kernel versions compatibility.
drivers/atm/he.c | 67 +++++++++++++++++++++++++++++++++++++------------------------------
1 files changed, 37 insertions(+), 30 deletions(-)
diff -puN drivers/atm/he.c~drivers-atm-he-chas drivers/atm/he.c
--- linux-2.5.69-1.1042.92.10-to-1.1097/drivers/atm/he.c~drivers-atm-he-chas Thu May 8 14:02:28 2003
+++ linux-2.5.69-1.1042.92.10-to-1.1097-fr/drivers/atm/he.c Thu May 8 15:13:56 2003
@@ -98,9 +98,16 @@ void sn_delete_polled_interrupt(int irq)
/* 2.2 kernel support */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,4)
+#define pci_set_drvdata(pdev,p) ((pdev)->driver_data = p)
+#define pci_get_drvdata(pdev) (pdev)->driver_data
+#endif
+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,43)
#define dev_kfree_skb_irq(skb) dev_kfree_skb(skb)
#define dev_kfree_skb_any(skb) dev_kfree_skb(skb)
+#define pci_disable_device(pdev) do {} while(0)
+#define pci_enable_device(pdev) 0
#undef USE_TASKLET
#endif
@@ -354,29 +361,30 @@ he_init_one(struct pci_dev *pci_dev, con
{
struct atm_dev *atm_dev;
struct he_dev *he_dev;
+ int ret = -EIO;
printk(KERN_INFO "he: %s\n", version);
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,43)
- if (pci_enable_device(pci_dev)) return -EIO;
-#endif
+ if (pci_enable_device(pci_dev))
+ goto out;
if (pci_set_dma_mask(pci_dev, HE_DMA_MASK) != 0)
{
printk(KERN_WARNING "he: no suitable dma available\n");
- return -EIO;
+ goto out_disable;
}
atm_dev = atm_dev_register(DEV_LABEL, &he_ops, -1, 0);
- if (!atm_dev) return -ENODEV;
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,3)
+ if (!atm_dev) {
+ ret = -ENODEV;
+ goto out_disable;
+ }
pci_set_drvdata(pci_dev, atm_dev);
-#else
- pci_dev->driver_data = atm_dev;
-#endif
- he_dev = (struct he_dev *) kmalloc(sizeof(struct he_dev),
- GFP_KERNEL);
- if (!he_dev) return -ENOMEM;
+ he_dev = (struct he_dev *) kmalloc(sizeof(*he_dev), GFP_KERNEL);
+ if (!he_dev) {
+ ret = -ENOMEM;
+ goto out_deregister;
+ }
memset(he_dev, 0, sizeof(struct he_dev));
he_dev->pci_dev = pci_dev;
@@ -385,16 +393,25 @@ he_init_one(struct pci_dev *pci_dev, con
HE_DEV(atm_dev) = he_dev;
he_dev->number = atm_dev->number; /* was devs */
if (he_start(atm_dev)) {
- atm_dev_deregister(atm_dev);
- he_stop(he_dev);
- kfree(he_dev);
- return -ENODEV;
+ ret = -ENODEV;
+ goto out_stop;
}
he_dev->next = NULL;
if (he_devs) he_dev->next = he_devs;
he_devs = he_dev;
- return 0;
+ ret = 0;
+out:
+ return ret;
+
+out_stop:
+ he_stop(he_dev);
+ kfree(he_dev);
+out_deregister:
+ atm_dev_deregister(atm_dev);
+out_disable:
+ pci_disable_device(pci_dev);
+ goto out;
}
static void __devexit
@@ -403,11 +420,7 @@ he_remove_one (struct pci_dev *pci_dev)
struct atm_dev *atm_dev;
struct he_dev *he_dev;
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,3)
atm_dev = pci_get_drvdata(pci_dev);
-#else
- atm_dev = pci_dev->driver_data;
-#endif
he_dev = HE_DEV(atm_dev);
/* need to remove from he_devs */
@@ -416,11 +429,8 @@ he_remove_one (struct pci_dev *pci_dev)
atm_dev_deregister(atm_dev);
kfree(he_dev);
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,3)
pci_set_drvdata(pci_dev, NULL);
-#else
- pci_dev->driver_data = NULL;
-#endif
+ pci_disable_device(pci_dev);
}
@@ -3384,13 +3394,10 @@ he_init()
static void __devexit
he_cleanup(void)
{
- while (he_devs)
- {
+ while (he_devs) {
struct he_dev *next = he_devs->next;
- he_stop(he_devs);
- atm_dev_deregister(he_devs->atm_dev);
- kfree(he_devs);
+ he_remove_one(he_dev->pci_dev);
he_devs = next;
}
prev parent reply other threads:[~2003-05-08 13:09 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200305071813.h47IDpc9010906@hera.kernel.org>
2003-05-07 23:01 ` Francois Romieu
2003-05-08 5:06 ` Christoph Hellwig
2003-05-08 10:08 ` Francois Romieu
2003-05-08 10:54 ` David S. Miller
2003-05-08 22:47 ` Werner Almesberger
2003-05-09 0:58 ` chas williams
2003-05-09 1:23 ` David S. Miller
2003-05-09 22:02 ` [ATM] [UPDATE] " Francois Romieu
2003-05-09 23:38 ` [ATM] [UPDATE] unbalanced exit path in Forerunner HE he_init_one() (and an iphase patch too!) chas williams
2003-05-10 5:20 ` Christoph Hellwig
2003-05-10 13:52 ` chas williams
2003-05-10 14:02 ` David S. Miller
2003-05-10 15:18 ` chas williams
2003-05-10 15:25 ` David S. Miller
2003-05-10 14:43 ` Christoph Hellwig
2003-05-10 16:12 ` Greg KH
2003-05-10 19:39 ` [USB] [PATCH] Crud-- (was: Re: [ATM] [UPDATE] unbalanced usw) Francois Romieu
2003-05-10 21:01 ` Francois Romieu
2003-05-10 23:04 ` Francois Romieu
2003-05-13 20:10 ` Greg KH
2003-05-10 10:54 ` [ATM] [UPDATE] unbalanced exit path in Forerunner HE he_init_one() (and an iphase patch too!) Francois Romieu
2003-05-08 12:20 ` [ATM] [PATCH] unbalanced exit path in Forerunner HE he_init_one() chas williams
2003-05-08 13:18 ` Francois Romieu [this message]
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=20030508151840.C26472@electric-eye.fr.zoreil.com \
--to=romieu@fr.zoreil.com \
--cc=chas@locutus.cmf.nrl.navy.mil \
--cc=davem@redhat.com \
--cc=linux-kernel@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®