ecashin@coraid.com [PATCH] aoe: fix __init calling __exit ChangeSet 1.2333, 2005/01/14 12:09:10-08:00, ecashin@coraid.com [PATCH] aoe: fix __init calling __exit Russell King writes: > static void __exit > aoe_exit(void) > { > ... > } > > static int __init > aoe_init(void) > { > ... > aoe_exit(); > ... > } Thanks for catching that. I cleaned up the error handling, too. Don't call __exit functions from __init functions. Signed-off-by: Ed L. Cashin Signed-off-by: Greg Kroah-Hartman drivers/block/aoe/aoechr.c | 2 +- drivers/block/aoe/aoedev.c | 2 +- drivers/block/aoe/aoemain.c | 44 +++++++++++++++++++++++++++++++------------- drivers/block/aoe/aoenet.c | 2 +- 4 files changed, 34 insertions(+), 16 deletions(-) diff -Nru a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c --- a/drivers/block/aoe/aoechr.c 2005-01-17 13:34:56 -08:00 +++ b/drivers/block/aoe/aoechr.c 2005-01-17 13:34:56 -08:00 @@ -266,7 +266,7 @@ return 0; } -void __exit +void aoechr_exit(void) { int i; diff -Nru a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c --- a/drivers/block/aoe/aoedev.c 2005-01-17 13:34:56 -08:00 +++ b/drivers/block/aoe/aoedev.c 2005-01-17 13:34:56 -08:00 @@ -151,7 +151,7 @@ kfree(d); } -void __exit +void aoedev_exit(void) { struct aoedev *d; diff -Nru a/drivers/block/aoe/aoemain.c b/drivers/block/aoe/aoemain.c --- a/drivers/block/aoe/aoemain.c 2005-01-17 13:34:56 -08:00 +++ b/drivers/block/aoe/aoemain.c 2005-01-17 13:34:56 -08:00 @@ -53,7 +53,7 @@ } } -static void __exit +static void aoe_exit(void) { discover_timer(TKILL); @@ -68,25 +68,43 @@ static int __init aoe_init(void) { - int n, (**p)(void); - int (*fns[])(void) = { - aoedev_init, aoechr_init, aoeblk_init, aoenet_init, NULL - }; + int ret; - for (p=fns; *p != NULL; p++) { - n = (*p)(); - if (n) { - aoe_exit(); - printk(KERN_INFO "aoe: aoe_init: initialisation failure.\n"); - return n; - } + ret = aoedev_init(); + if (ret) + return ret; + ret = aoechr_init(); + if (ret) + goto chr_fail; + ret = aoeblk_init(); + if (ret) + goto blk_fail; + ret = aoenet_init(); + if (ret) + goto net_fail; + ret = register_blkdev(AOE_MAJOR, DEVICE_NAME); + if (ret < 0) { + printk(KERN_ERR "aoe: aoeblk_init: can't register major\n"); + goto blkreg_fail; } + printk(KERN_INFO "aoe: aoe_init: AoE v2.6-%s initialised.\n", VERSION); - discover_timer(TINIT); return 0; + + blkreg_fail: + aoenet_exit(); + net_fail: + aoeblk_exit(); + blk_fail: + aoechr_exit(); + chr_fail: + aoedev_exit(); + + printk(KERN_INFO "aoe: aoe_init: initialisation failure.\n"); + return ret; } module_init(aoe_init); diff -Nru a/drivers/block/aoe/aoenet.c b/drivers/block/aoe/aoenet.c --- a/drivers/block/aoe/aoenet.c 2005-01-17 13:34:56 -08:00 +++ b/drivers/block/aoe/aoenet.c 2005-01-17 13:34:56 -08:00 @@ -164,7 +164,7 @@ return 0; } -void __exit +void aoenet_exit(void) { dev_remove_pack(&aoe_pt);