qla4xxx: Fix memory leak for ha->saved_acb
authorNilesh Javali <nilesh.javali@qlogic.com>
Thu, 10 Apr 2014 01:12:26 +0000 (21:12 -0400)
committerChristoph Hellwig <hch@lst.de>
Mon, 19 May 2014 17:12:19 +0000 (19:12 +0200)
Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/scsi/qla4xxx/ql4_mbx.c

index 1345c0eaa6d7fe71a42c2cbf076b08f424e7a305..0a3312c6dd6d5fb5ba03001e7bd8b4a5e34470f0 100644 (file)
@@ -2395,8 +2395,6 @@ int qla4_84xx_config_acb(struct scsi_qla_host *ha, int acb_config)
                }
 
                memcpy(acb, ha->saved_acb, acb_len);
-               kfree(ha->saved_acb);
-               ha->saved_acb = NULL;
 
                rval = qla4xxx_set_acb(ha, &mbox_cmd[0], &mbox_sts[0], acb_dma);
                if (rval != QLA_SUCCESS)
@@ -2412,6 +2410,10 @@ exit_free_acb:
        dma_free_coherent(&ha->pdev->dev, sizeof(struct addr_ctrl_blk), acb,
                          acb_dma);
 exit_config_acb:
+       if ((acb_config == ACB_CONFIG_SET) && ha->saved_acb) {
+               kfree(ha->saved_acb);
+               ha->saved_acb = NULL;
+       }
        DEBUG2(ql4_printk(KERN_INFO, ha,
                          "%s %s\n", __func__,
                          rval == QLA_SUCCESS ? "SUCCEEDED" : "FAILED"));