diff options
Diffstat (limited to 'block/bsg.c')
-rw-r--r-- | block/bsg.c | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/block/bsg.c b/block/bsg.c index cdb00e5544b1..b25378459ff0 100644 --- a/block/bsg.c +++ b/block/bsg.c | |||
@@ -1057,39 +1057,37 @@ static int __init bsg_init(void) | |||
1057 | 1057 | ||
1058 | bsg_class = class_create(THIS_MODULE, "bsg"); | 1058 | bsg_class = class_create(THIS_MODULE, "bsg"); |
1059 | if (IS_ERR(bsg_class)) { | 1059 | if (IS_ERR(bsg_class)) { |
1060 | kmem_cache_destroy(bsg_cmd_cachep); | 1060 | ret = PTR_ERR(bsg_class); |
1061 | return PTR_ERR(bsg_class); | 1061 | goto destroy_kmemcache; |
1062 | } | 1062 | } |
1063 | 1063 | ||
1064 | ret = alloc_chrdev_region(&devid, 0, BSG_MAX_DEVS, "bsg"); | 1064 | ret = alloc_chrdev_region(&devid, 0, BSG_MAX_DEVS, "bsg"); |
1065 | if (ret) { | 1065 | if (ret) |
1066 | kmem_cache_destroy(bsg_cmd_cachep); | 1066 | goto destroy_bsg_class; |
1067 | class_destroy(bsg_class); | ||
1068 | return ret; | ||
1069 | } | ||
1070 | 1067 | ||
1071 | bsg_major = MAJOR(devid); | 1068 | bsg_major = MAJOR(devid); |
1072 | 1069 | ||
1073 | cdev_init(&bsg_cdev, &bsg_fops); | 1070 | cdev_init(&bsg_cdev, &bsg_fops); |
1074 | ret = cdev_add(&bsg_cdev, MKDEV(bsg_major, 0), BSG_MAX_DEVS); | 1071 | ret = cdev_add(&bsg_cdev, MKDEV(bsg_major, 0), BSG_MAX_DEVS); |
1075 | if (ret) { | 1072 | if (ret) |
1076 | kmem_cache_destroy(bsg_cmd_cachep); | 1073 | goto unregister_chrdev; |
1077 | class_destroy(bsg_class); | ||
1078 | unregister_chrdev_region(MKDEV(bsg_major, 0), BSG_MAX_DEVS); | ||
1079 | return ret; | ||
1080 | } | ||
1081 | 1074 | ||
1082 | ret = scsi_register_interface(&bsg_intf); | 1075 | ret = scsi_register_interface(&bsg_intf); |
1083 | if (ret) { | 1076 | if (ret) |
1084 | printk(KERN_ERR "bsg: failed register scsi interface %d\n", ret); | 1077 | goto remove_cdev; |
1085 | kmem_cache_destroy(bsg_cmd_cachep); | ||
1086 | class_destroy(bsg_class); | ||
1087 | unregister_chrdev(bsg_major, "bsg"); | ||
1088 | return ret; | ||
1089 | } | ||
1090 | 1078 | ||
1091 | printk(KERN_INFO "%s loaded (major %d)\n", bsg_version, bsg_major); | 1079 | printk(KERN_INFO "%s loaded (major %d)\n", bsg_version, bsg_major); |
1092 | return 0; | 1080 | return 0; |
1081 | remove_cdev: | ||
1082 | printk(KERN_ERR "bsg: failed register scsi interface %d\n", ret); | ||
1083 | cdev_del(&bsg_cdev); | ||
1084 | unregister_chrdev: | ||
1085 | unregister_chrdev_region(MKDEV(bsg_major, 0), BSG_MAX_DEVS); | ||
1086 | destroy_bsg_class: | ||
1087 | class_destroy(bsg_class); | ||
1088 | destroy_kmemcache: | ||
1089 | kmem_cache_destroy(bsg_cmd_cachep); | ||
1090 | return ret; | ||
1093 | } | 1091 | } |
1094 | 1092 | ||
1095 | MODULE_AUTHOR("Jens Axboe"); | 1093 | MODULE_AUTHOR("Jens Axboe"); |