Commit 3d9dd6ee authored by FUJITA Tomonori's avatar FUJITA Tomonori Committed by James Bottomley

[SCSI] handle scsi_init_queue failure properly

scsi_init_queue is expected to clean up allocated things when it
fails.
Signed-off-by: default avatarFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
parent b172b6e9
...@@ -1682,7 +1682,7 @@ int __init scsi_init_queue(void) ...@@ -1682,7 +1682,7 @@ int __init scsi_init_queue(void)
0, 0, NULL); 0, 0, NULL);
if (!scsi_bidi_sdb_cache) { if (!scsi_bidi_sdb_cache) {
printk(KERN_ERR "SCSI: can't init scsi bidi sdb cache\n"); printk(KERN_ERR "SCSI: can't init scsi bidi sdb cache\n");
return -ENOMEM; goto cleanup_io_context;
} }
for (i = 0; i < SG_MEMPOOL_NR; i++) { for (i = 0; i < SG_MEMPOOL_NR; i++) {
...@@ -1694,6 +1694,7 @@ int __init scsi_init_queue(void) ...@@ -1694,6 +1694,7 @@ int __init scsi_init_queue(void)
if (!sgp->slab) { if (!sgp->slab) {
printk(KERN_ERR "SCSI: can't init sg slab %s\n", printk(KERN_ERR "SCSI: can't init sg slab %s\n",
sgp->name); sgp->name);
goto cleanup_bidi_sdb;
} }
sgp->pool = mempool_create_slab_pool(SG_MEMPOOL_SIZE, sgp->pool = mempool_create_slab_pool(SG_MEMPOOL_SIZE,
...@@ -1701,10 +1702,25 @@ int __init scsi_init_queue(void) ...@@ -1701,10 +1702,25 @@ int __init scsi_init_queue(void)
if (!sgp->pool) { if (!sgp->pool) {
printk(KERN_ERR "SCSI: can't init sg mempool %s\n", printk(KERN_ERR "SCSI: can't init sg mempool %s\n",
sgp->name); sgp->name);
goto cleanup_bidi_sdb;
} }
} }
return 0; return 0;
cleanup_bidi_sdb:
for (i = 0; i < SG_MEMPOOL_NR; i++) {
struct scsi_host_sg_pool *sgp = scsi_sg_pools + i;
if (sgp->pool)
mempool_destroy(sgp->pool);
if (sgp->slab)
kmem_cache_destroy(sgp->slab);
}
kmem_cache_destroy(scsi_bidi_sdb_cache);
cleanup_io_context:
kmem_cache_destroy(scsi_io_context_cache);
return -ENOMEM;
} }
void scsi_exit_queue(void) void scsi_exit_queue(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment