[3.5.y.z,extended,stable] Patch "[SCSI] sd: Reshuffle init_sd to avoid crash" has been added to staging queue

Message ID 1358977201-24269-1-git-send-email-herton.krzesinski@canonical.com
State New
Headers show

Commit Message

Herton Ronaldo Krzesinski Jan. 23, 2013, 9:40 p.m.
This is a note to let you know that I have just added a patch titled

    [SCSI] sd: Reshuffle init_sd to avoid crash

to the linux-3.5.y-queue branch of the 3.5.y.z extended stable tree 
which can be found at:


If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.5.y.z tree, see



From e17ffb6bb4710bc00df789196853c0d470b31f14 Mon Sep 17 00:00:00 2001
From: "Joel D. Diaz" <joeldiaz@us.ibm.com>
Date: Wed, 10 Oct 2012 10:36:11 +0200
Subject: [PATCH] [SCSI] sd: Reshuffle init_sd to avoid crash

commit afd5e34b2bb34881d3a789e62486814a49b47faa 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: Joel D. Diaz <joeldiaz@us.ibm.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
 drivers/scsi/sd.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)



diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 6f72b80..043395d0 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2920,10 +2920,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) {
@@ -2937,8 +2933,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;

+	mempool_destroy(sd_cdb_pool);

@@ -2961,10 +2964,10 @@  static void __exit exit_sd(void)

 	SCSI_LOG_HLQUEUE(3, printk("exit_sd: exiting sd driver\n"));

+	scsi_unregister_driver(&sd_template.gendrv);

-	scsi_unregister_driver(&sd_template.gendrv);

 	for (i = 0; i < SD_MAJORS; i++)