Skip to content

Commit

Permalink
[PATCH] tokenring: fix module_init error handling
Browse files Browse the repository at this point in the history
- 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(-)
Signed-off-by: Jeff Garzik <jeff@garzik.org>
  • Loading branch information
Akinobu Mita authored and Jeff Garzik committed Nov 1, 2006
1 parent 06f0015 commit 9d4df9e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions drivers/net/tokenring/proteon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions drivers/net/tokenring/skisa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down

0 comments on commit 9d4df9e

Please sign in to comment.