aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Gross <jgross@suse.com>2014-08-04 07:30:02 -0400
committerJames Bottomley <JBottomley@Parallels.com>2014-08-15 15:46:46 -0400
commitf6105c0808880c2c432b79bc81b37cc244c300c8 (patch)
tree751d9efb50f0f180f4733a2563c16a173e0e3b1d
parent045065d8a300a37218c548e9aa7becd581c6a0e8 (diff)
[SCSI] save command pool address of Scsi_Host
If a scsi host driver specifies .cmd_len in it's scsi_host_template, a driver's private command pool is needed. scsi_find_host_cmd_pool() will locate it, but scsi_alloc_host_cmd_pool() isn't saving the pool address in the host template. This will result in an access error when the host is removed. Avoid the problem by saving the address of a new allocated command pool where it is expected. Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Christoph Hellwig <hch@lst.de> Fixes: 89d9a567952baec13e26ada3e438f1b642d66b6e Cc: stable@vger.kernel.org Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r--drivers/scsi/scsi.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index df3306019a7e..d81f3cc43ff1 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -377,6 +377,10 @@ scsi_alloc_host_cmd_pool(struct Scsi_Host *shost)
377 pool->slab_flags |= SLAB_CACHE_DMA; 377 pool->slab_flags |= SLAB_CACHE_DMA;
378 pool->gfp_mask = __GFP_DMA; 378 pool->gfp_mask = __GFP_DMA;
379 } 379 }
380
381 if (hostt->cmd_size)
382 hostt->cmd_pool = pool;
383
380 return pool; 384 return pool;
381} 385}
382 386
@@ -421,8 +425,10 @@ out:
421out_free_slab: 425out_free_slab:
422 kmem_cache_destroy(pool->cmd_slab); 426 kmem_cache_destroy(pool->cmd_slab);
423out_free_pool: 427out_free_pool:
424 if (hostt->cmd_size) 428 if (hostt->cmd_size) {
425 scsi_free_host_cmd_pool(pool); 429 scsi_free_host_cmd_pool(pool);
430 hostt->cmd_pool = NULL;
431 }
426 goto out; 432 goto out;
427} 433}
428 434
@@ -444,8 +450,10 @@ static void scsi_put_host_cmd_pool(struct Scsi_Host *shost)
444 if (!--pool->users) { 450 if (!--pool->users) {
445 kmem_cache_destroy(pool->cmd_slab); 451 kmem_cache_destroy(pool->cmd_slab);
446 kmem_cache_destroy(pool->sense_slab); 452 kmem_cache_destroy(pool->sense_slab);
447 if (hostt->cmd_size) 453 if (hostt->cmd_size) {
448 scsi_free_host_cmd_pool(pool); 454 scsi_free_host_cmd_pool(pool);
455 hostt->cmd_pool = NULL;
456 }
449 } 457 }
450 mutex_unlock(&host_cmd_pool_mutex); 458 mutex_unlock(&host_cmd_pool_mutex);
451} 459}