summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sd.c
diff options
context:
space:
mode:
authorJoel D. Diaz <joeldiaz@us.ibm.com>2012-10-10 04:36:11 -0400
committerJames Bottomley <JBottomley@Parallels.com>2012-11-26 23:59:34 -0500
commitafd5e34b2bb34881d3a789e62486814a49b47faa (patch)
treee289c2ef0d8be9b007423e3c7eda3440e788092f /drivers/scsi/sd.c
parent500c152afbafba2adcb23bb2e37b7138eb003b7f (diff)
[SCSI] sd: Reshuffle init_sd to avoid crash
scsi_register_driver will register a prep_fn() function, which in turn migh need to use the sd_cdp_pool for DIF. Which hasn't been initialised at this point, leading to a crash. So reshuffle the init_sd() and exit_sd() paths to have the driver registered last. Signed-off-by: Joel D. Diaz <joeldiaz@us.ibm.com> Signed-off-by: Hannes Reinecke <hare@suse.de> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/sd.c')
-rw-r--r--drivers/scsi/sd.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 352bc77b7c88..a45e12ac7e28 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3116,10 +3116,6 @@ static int __init init_sd(void)
3116 if (err) 3116 if (err)
3117 goto err_out; 3117 goto err_out;
3118 3118
3119 err = scsi_register_driver(&sd_template.gendrv);
3120 if (err)
3121 goto err_out_class;
3122
3123 sd_cdb_cache = kmem_cache_create("sd_ext_cdb", SD_EXT_CDB_SIZE, 3119 sd_cdb_cache = kmem_cache_create("sd_ext_cdb", SD_EXT_CDB_SIZE,
3124 0, 0, NULL); 3120 0, 0, NULL);
3125 if (!sd_cdb_cache) { 3121 if (!sd_cdb_cache) {
@@ -3133,8 +3129,15 @@ static int __init init_sd(void)
3133 goto err_out_cache; 3129 goto err_out_cache;
3134 } 3130 }
3135 3131
3132 err = scsi_register_driver(&sd_template.gendrv);
3133 if (err)
3134 goto err_out_driver;
3135
3136 return 0; 3136 return 0;
3137 3137
3138err_out_driver:
3139 mempool_destroy(sd_cdb_pool);
3140
3138err_out_cache: 3141err_out_cache:
3139 kmem_cache_destroy(sd_cdb_cache); 3142 kmem_cache_destroy(sd_cdb_cache);
3140 3143
@@ -3157,10 +3160,10 @@ static void __exit exit_sd(void)
3157 3160
3158 SCSI_LOG_HLQUEUE(3, printk("exit_sd: exiting sd driver\n")); 3161 SCSI_LOG_HLQUEUE(3, printk("exit_sd: exiting sd driver\n"));
3159 3162
3163 scsi_unregister_driver(&sd_template.gendrv);
3160 mempool_destroy(sd_cdb_pool); 3164 mempool_destroy(sd_cdb_pool);
3161 kmem_cache_destroy(sd_cdb_cache); 3165 kmem_cache_destroy(sd_cdb_cache);
3162 3166
3163 scsi_unregister_driver(&sd_template.gendrv);
3164 class_unregister(&sd_disk_class); 3167 class_unregister(&sd_disk_class);
3165 3168
3166 for (i = 0; i < SD_MAJORS; i++) 3169 for (i = 0; i < SD_MAJORS; i++)