[PATCH 3/5] qla2xxx: Free DMA memory only if it is allocated in vendor specific BSG command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Harish Zunjarrao <harish.zunjarrao@xxxxxxxxxx>

The qla84xx_mgmt_cmd function supports multiple subcommands.
Some subcommands require DMA memory and some do not.
Therefore check before freeing DMA memory whether it is allocated or not.

Signed-off-by: Harish Zunjarrao <harish.zunjarrao@xxxxxxxxxx>
Signed-off-by: Giridhar Malavali <giridhar.malavali@xxxxxxxxxx>
---
 drivers/scsi/qla2xxx/qla_bsg.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c
index 239d37b..dc8bf10 100644
--- a/drivers/scsi/qla2xxx/qla_bsg.c
+++ b/drivers/scsi/qla2xxx/qla_bsg.c
@@ -804,7 +804,7 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job)
 	int rval = 0;
 	struct qla_bsg_a84_mgmt *ql84_mgmt;
 	uint32_t sg_cnt;
-	uint32_t data_len;
+	uint32_t data_len = 0;
 	uint32_t dma_direction = DMA_NONE;
 
 	if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
@@ -980,9 +980,11 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job)
 	}
 
 	bsg_job->job_done(bsg_job);
-	dma_free_coherent(&ha->pdev->dev, data_len, mgmt_b, mgmt_dma);
 
 done_unmap_sg:
+	if (mgmt_b)
+		dma_free_coherent(&ha->pdev->dev, data_len, mgmt_b, mgmt_dma);
+
 	if (dma_direction == DMA_TO_DEVICE)
 		dma_unmap_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list,
 			bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE);
-- 
1.6.2.rc1.30.gd43c

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux