[PATCH] 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 joeld...@us.ibm.com Signed-off-by: Hannes Reinecke h...@suse.de --- drivers/scsi/sd.c | 13 - 1 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 12f6fdf..a88c34e 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -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++) -- 1.7.4.2 -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] sd: Reshuffle init_sd to avoid crash
On Wed, 2012-10-10 at 10:36 +0200, Hannes Reinecke wrote: 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 joeld...@us.ibm.com Signed-off-by: Hannes Reinecke h...@suse.de Explain what these signoffs mean, since the patch is sent with you as the author. Thanks, James -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] sd: Reshuffle init_sd to avoid crash
On 10/10/2012 11:55 AM, James Bottomley wrote: On Wed, 2012-10-10 at 10:36 +0200, Hannes Reinecke wrote: 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 joeld...@us.ibm.com Signed-off-by: Hannes Reinecke h...@suse.de 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 -- Dr. Hannes Reinecke zSeries Storage h...@suse.de +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 majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] sd: Reshuffle init_sd to avoid crash
On Wed, 2012-10-10 at 12:01 +0200, Hannes Reinecke wrote: On 10/10/2012 11:55 AM, James Bottomley wrote: On Wed, 2012-10-10 at 10:36 +0200, Hannes Reinecke wrote: 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 joeld...@us.ibm.com Signed-off-by: Hannes Reinecke h...@suse.de 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? That's OK, I can fix this up on the fly (this time). James -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html