[SCSI] qla2xxx: Fix memory leak in error path
authorAnirban Chakraborty <anirban.chakraborty@qlogic.com>
Thu, 22 Jan 2009 17:45:28 +0000 (09:45 -0800)
committerJames Bottomley <James.Bottomley@HansenPartnership.com>
Sun, 25 Jan 2009 13:55:42 +0000 (07:55 -0600)
Reviewed-by: Hisashi Hifumi <hifumi.hisashi@oss.ntt.co.jp>
Signed-off-by: Anirban Chakraborty <anirban.chakraborty@qlogic.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
drivers/scsi/qla2xxx/qla_os.c

index cf32653fe01a2317aee14dae3856c2aee8017953..185ea8bcb9e275252a19ebf25ceecf2a48c19d79 100644 (file)
@@ -1888,6 +1888,8 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
                    "[ERROR] Failed to allocate memory for scsi_host\n");
 
                ret = -ENOMEM;
+               qla2x00_mem_free(ha);
+               qla2x00_free_que(ha, req, rsp);
                goto probe_hw_failed;
        }
 
@@ -1917,14 +1919,13 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
        /* Set up the irqs */
        ret = qla2x00_request_irqs(ha, rsp);
        if (ret)
-               goto probe_failed;
-
+               goto probe_init_failed;
        /* Alloc arrays of request and response ring ptrs */
        if (!qla2x00_alloc_queues(ha)) {
                qla_printk(KERN_WARNING, ha,
                "[ERROR] Failed to allocate memory for queue"
                " pointers\n");
-               goto probe_failed;
+               goto probe_init_failed;
        }
        ha->rsp_q_map[0] = rsp;
        ha->req_q_map[0] = req;
@@ -1997,6 +1998,10 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
 
        return 0;
 
+probe_init_failed:
+       qla2x00_free_que(ha, req, rsp);
+       ha->max_queues = 0;
+
 probe_failed:
        qla2x00_free_device(base_vha);