Commit 0aa31f18 authored by Joel D. Diaz's avatar Joel D. Diaz Committed by Greg Kroah-Hartman

SCSI: sd: Reshuffle init_sd to avoid crash

commit afd5e34b upstream.

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: default avatarJoel D. Diaz <joeldiaz@us.ibm.com>
Signed-off-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
Cc: CAI Qian <caiqian@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 27b2a263
...@@ -2826,10 +2826,6 @@ static int __init init_sd(void) ...@@ -2826,10 +2826,6 @@ static int __init init_sd(void)
if (err) if (err)
goto err_out; goto err_out;
err = scsi_register_driver(&sd_template.gendrv);
if (err)
goto err_out_class;
sd_cdb_cache = kmem_cache_create("sd_ext_cdb", SD_EXT_CDB_SIZE, sd_cdb_cache = kmem_cache_create("sd_ext_cdb", SD_EXT_CDB_SIZE,
0, 0, NULL); 0, 0, NULL);
if (!sd_cdb_cache) { if (!sd_cdb_cache) {
...@@ -2843,8 +2839,15 @@ static int __init init_sd(void) ...@@ -2843,8 +2839,15 @@ static int __init init_sd(void)
goto err_out_cache; goto err_out_cache;
} }
err = scsi_register_driver(&sd_template.gendrv);
if (err)
goto err_out_driver;
return 0; return 0;
err_out_driver:
mempool_destroy(sd_cdb_pool);
err_out_cache: err_out_cache:
kmem_cache_destroy(sd_cdb_cache); kmem_cache_destroy(sd_cdb_cache);
...@@ -2867,10 +2870,10 @@ static void __exit exit_sd(void) ...@@ -2867,10 +2870,10 @@ static void __exit exit_sd(void)
SCSI_LOG_HLQUEUE(3, printk("exit_sd: exiting sd driver\n")); SCSI_LOG_HLQUEUE(3, printk("exit_sd: exiting sd driver\n"));
scsi_unregister_driver(&sd_template.gendrv);
mempool_destroy(sd_cdb_pool); mempool_destroy(sd_cdb_pool);
kmem_cache_destroy(sd_cdb_cache); kmem_cache_destroy(sd_cdb_cache);
scsi_unregister_driver(&sd_template.gendrv);
class_unregister(&sd_disk_class); class_unregister(&sd_disk_class);
for (i = 0; i < SD_MAJORS; i++) for (i = 0; i < SD_MAJORS; i++)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment