sd: Reshuffle init_sd to avoid crash
PATCH 1/1 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.
--- drivers/scsi/sd.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)
drivers/scsi/sd.c +8 -5
@@ -2960,10 +2960,6 @@ static int __init init_sd(void)if (err) 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 ,0 ,0 ,NULL );if (!sd_cdb_cache) {
@@ -2977,8 +2973,15 @@ static int __init init_sd(void) goto err_out_cache; } + err =scsi_register_driver (&sd_template.gendrv); +if (err) + goto err_out_driver; +return 0 ; +err_out_driver: +mempool_destroy (sd_cdb_pool); + err_out_cache:kmem_cache_destroy (sd_cdb_cache);
@@ -3001,10 +3004,10 @@ static void __exit exit_sd(void)SCSI_LOG_HLQUEUE (3 ,printk ("exit_sd: exiting sd driver\n" )); +scsi_unregister_driver (&sd_template.gendrv);mempool_destroy (sd_cdb_pool);kmem_cache_destroy (sd_cdb_cache); -scsi_unregister_driver (&sd_template.gendrv);class_unregister (&sd_disk_class);for (i =0 ; i <SD_MAJORS ; i++)
Signature · 1 line
1.7.4.2
James Bottomley
maintainerQuoted 8 lines · Hannes Reinecke
scsi_register_driverwill register aprep_fn()function, which in turn migh need to use thesd_cdp_poolfor DIF. Which hasn't been initialised at this point, leading to a crash. So reshuffle theinit_sd()andexit_sd()paths to have the driver registered last.Signed-off-by Joel D. Diaz <[email protected]>Signed-off-by Hannes Reinecke <[email protected]>
Explain what these signoffs mean, since the patch is sent with you as the author.
Thanks,
James
Quoted 7 lines · James Bottomley
Quoted 6 lines · Hannes Reinecke
scsi_register_driverwill register aprep_fn()function, which in turn migh need to use thesd_cdp_poolfor DIF. Which hasn't been initialised at this point, leading to a crash. So reshuffle theinit_sd()andexit_sd()paths to have the driver registered last.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Joel D. Diaz <[email protected]>Signed-off-by Hannes Reinecke <[email protected]>Explain what these signoffs mean, since the patch is sent with you as the author.
Ah. Sorry.
Joel Diaz send the patch relative to SLES11 SP2, and I ported / send it to mainline.
So yeah, Joel is actually the author.
Should I send an updated patch?
Cheers,
Hannes
Signature · 8 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg) -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
James Bottomley
maintainerQuoted 14 lines · Hannes Reinecke
Quoted 7 lines · James Bottomley
Quoted 6 lines · Hannes Reinecke
scsi_register_driverwill register aprep_fn()function, which in turn migh need to use thesd_cdp_poolfor DIF. Which hasn't been initialised at this point, leading to a crash. So reshuffle theinit_sd()andexit_sd()paths to have the driver registered last.Quoted 6 lines
Quoted 2 lines
Signed-off-by Joel D. Diaz <[email protected]>Signed-off-by Hannes Reinecke <[email protected]>Explain what these signoffs mean, since the patch is sent with you as the author.
Quoted 6 lines
Ah. Sorry.
Joel Diaz send the patch relative to SLES11 SP2, and I ported / send it to mainline.So yeah, Joel is actually the author.
Should I send an updated patch?
That's OK, I can fix this up on the fly (this time).
James