From: Akinobu Mita <akinobu.mita@gmail.com>
To: linux-kernel@vger.kernel.org, linux-netdev@vger.kernel.org
Cc: Jeff Garzik <jgarzik@pobox.com>, Mike Phillips <mikep@linuxtr.net>
Subject: [PATCH] tokenring: fix module_init error handling
Date: Sun, 29 Oct 2006 03:52:14 +0900 [thread overview]
Message-ID: <20061028185214.GJ9973@localhost> (raw)
- Call platform_driver_unregister() before return when no cards found.
(fixes data corruption when no cards found)
- Check platform_device_register_simple() return value
Cc: Jeff Garzik <jgarzik@pobox.com>
Cc: Mike Phillips <mikep@linuxtr.net>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
drivers/net/tokenring/proteon.c | 9 +++++++--
drivers/net/tokenring/skisa.c | 9 +++++++--
2 files changed, 14 insertions(+), 4 deletions(-)
Index: work-fault-inject/drivers/net/tokenring/proteon.c
===================================================================
--- work-fault-inject.orig/drivers/net/tokenring/proteon.c
+++ work-fault-inject/drivers/net/tokenring/proteon.c
@@ -370,6 +370,10 @@ static int __init proteon_init(void)
dev->dma = dma[i];
pdev = platform_device_register_simple("proteon",
i, NULL, 0);
+ if (IS_ERR(pdev)) {
+ free_netdev(dev);
+ continue;
+ }
err = setup_card(dev, &pdev->dev);
if (!err) {
proteon_dev[i] = pdev;
@@ -385,9 +389,10 @@ static int __init proteon_init(void)
/* Probe for cards. */
if (num == 0) {
printk(KERN_NOTICE "proteon.c: No cards found.\n");
- return (-ENODEV);
+ platform_driver_unregister(&proteon_driver);
+ return -ENODEV;
}
- return (0);
+ return 0;
}
static void __exit proteon_cleanup(void)
Index: work-fault-inject/drivers/net/tokenring/skisa.c
===================================================================
--- work-fault-inject.orig/drivers/net/tokenring/skisa.c
+++ work-fault-inject/drivers/net/tokenring/skisa.c
@@ -380,6 +380,10 @@ static int __init sk_isa_init(void)
dev->dma = dma[i];
pdev = platform_device_register_simple("skisa",
i, NULL, 0);
+ if (IS_ERR(pdev)) {
+ free_netdev(dev);
+ continue;
+ }
err = setup_card(dev, &pdev->dev);
if (!err) {
sk_isa_dev[i] = pdev;
@@ -395,9 +399,10 @@ static int __init sk_isa_init(void)
/* Probe for cards. */
if (num == 0) {
printk(KERN_NOTICE "skisa.c: No cards found.\n");
- return (-ENODEV);
+ platform_driver_unregister(&sk_isa_driver);
+ return -ENODEV;
}
- return (0);
+ return 0;
}
static void __exit sk_isa_cleanup(void)
next reply other threads:[~2006-10-28 18:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-28 18:52 Akinobu Mita [this message]
2006-11-01 1:20 ` [PATCH] tokenring: fix module_init error handling Jeff Garzik
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=20061028185214.GJ9973@localhost \
--to=akinobu.mita@gmail.com \
--cc=jgarzik@pobox.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-netdev@vger.kernel.org \
--cc=mikep@linuxtr.net \
/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