aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFUJITA Tomonori <tomof@acm.org>2008-01-25 09:25:14 -0500
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-01-30 14:14:25 -0500
commit3d9dd6eef888658d26ebea0cc24d15d2a93ab015 (patch)
treef3882779400f1ac10469e3f76ea544408712c1b2
parentb172b6e99e948b6abb180082cfeb8f9b1450ebff (diff)
[SCSI] handle scsi_init_queue failure properly
scsi_init_queue is expected to clean up allocated things when it fails. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
-rw-r--r--drivers/scsi/scsi_lib.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 7bfec7e7a8a0..b12fb310e399 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1682,7 +1682,7 @@ int __init scsi_init_queue(void)
1682 0, 0, NULL); 1682 0, 0, NULL);
1683 if (!scsi_bidi_sdb_cache) { 1683 if (!scsi_bidi_sdb_cache) {
1684 printk(KERN_ERR "SCSI: can't init scsi bidi sdb cache\n"); 1684 printk(KERN_ERR "SCSI: can't init scsi bidi sdb cache\n");
1685 return -ENOMEM; 1685 goto cleanup_io_context;
1686 } 1686 }
1687 1687
1688 for (i = 0; i < SG_MEMPOOL_NR; i++) { 1688 for (i = 0; i < SG_MEMPOOL_NR; i++) {
@@ -1694,6 +1694,7 @@ int __init scsi_init_queue(void)
1694 if (!sgp->slab) { 1694 if (!sgp->slab) {
1695 printk(KERN_ERR "SCSI: can't init sg slab %s\n", 1695 printk(KERN_ERR "SCSI: can't init sg slab %s\n",
1696 sgp->name); 1696 sgp->name);
1697 goto cleanup_bidi_sdb;
1697 } 1698 }
1698 1699
1699 sgp->pool = mempool_create_slab_pool(SG_MEMPOOL_SIZE, 1700 sgp->pool = mempool_create_slab_pool(SG_MEMPOOL_SIZE,
@@ -1701,10 +1702,25 @@ int __init scsi_init_queue(void)
1701 if (!sgp->pool) { 1702 if (!sgp->pool) {
1702 printk(KERN_ERR "SCSI: can't init sg mempool %s\n", 1703 printk(KERN_ERR "SCSI: can't init sg mempool %s\n",
1703 sgp->name); 1704 sgp->name);
1705 goto cleanup_bidi_sdb;
1704 } 1706 }
1705 } 1707 }
1706 1708
1707 return 0; 1709 return 0;
1710
1711cleanup_bidi_sdb:
1712 for (i = 0; i < SG_MEMPOOL_NR; i++) {
1713 struct scsi_host_sg_pool *sgp = scsi_sg_pools + i;
1714 if (sgp->pool)
1715 mempool_destroy(sgp->pool);
1716 if (sgp->slab)
1717 kmem_cache_destroy(sgp->slab);
1718 }
1719 kmem_cache_destroy(scsi_bidi_sdb_cache);
1720cleanup_io_context:
1721 kmem_cache_destroy(scsi_io_context_cache);
1722
1723 return -ENOMEM;
1708} 1724}
1709 1725
1710void scsi_exit_queue(void) 1726void scsi_exit_queue(void)