All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sd: Reshuffle init_sd to avoid crash
@ 2012-10-10  8:36 Hannes Reinecke
  2012-10-10  9:55 ` James Bottomley
  0 siblings, 1 reply; 4+ messages in thread
From: Hannes Reinecke @ 2012-10-10  8:36 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-scsi, Hannes Reinecke, Joel D. Diaz

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>
---
 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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] sd: Reshuffle init_sd to avoid crash
  2012-10-10  8:36 [PATCH] sd: Reshuffle init_sd to avoid crash Hannes Reinecke
@ 2012-10-10  9:55 ` James Bottomley
  2012-10-10 10:01   ` Hannes Reinecke
  0 siblings, 1 reply; 4+ messages in thread
From: James Bottomley @ 2012-10-10  9:55 UTC (permalink / raw)
  To: Hannes Reinecke; +Cc: linux-scsi, Joel D. Diaz

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 <joeldiaz@us.ibm.com>
> Signed-off-by: Hannes Reinecke <hare@suse.de>

Explain what these signoffs mean, since the patch is sent with you as
the author.

Thanks,

James



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] sd: Reshuffle init_sd to avoid crash
  2012-10-10  9:55 ` James Bottomley
@ 2012-10-10 10:01   ` Hannes Reinecke
  2012-10-10 11:49     ` James Bottomley
  0 siblings, 1 reply; 4+ messages in thread
From: Hannes Reinecke @ 2012-10-10 10:01 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-scsi, Joel D. Diaz

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 <joeldiaz@us.ibm.com>
>> Signed-off-by: Hannes Reinecke <hare@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
hare@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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] sd: Reshuffle init_sd to avoid crash
  2012-10-10 10:01   ` Hannes Reinecke
@ 2012-10-10 11:49     ` James Bottomley
  0 siblings, 0 replies; 4+ messages in thread
From: James Bottomley @ 2012-10-10 11:49 UTC (permalink / raw)
  To: Hannes Reinecke; +Cc: linux-scsi, Joel D. Diaz

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 <joeldiaz@us.ibm.com>
> >> Signed-off-by: Hannes Reinecke <hare@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



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-10-10 11:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-10  8:36 [PATCH] sd: Reshuffle init_sd to avoid crash Hannes Reinecke
2012-10-10  9:55 ` James Bottomley
2012-10-10 10:01   ` Hannes Reinecke
2012-10-10 11:49     ` James Bottomley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.