Commit d5459083 authored by Harish Zunjarrao's avatar Harish Zunjarrao Committed by James Bottomley

[SCSI] qla2xxx: Free DMA memory only if it is allocated in vendor specific BSG command

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: default avatarHarish Zunjarrao <harish.zunjarrao@qlogic.com>
Signed-off-by: default avatarGiridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent 09ff701a
...@@ -804,7 +804,7 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job) ...@@ -804,7 +804,7 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job)
int rval = 0; int rval = 0;
struct qla_bsg_a84_mgmt *ql84_mgmt; struct qla_bsg_a84_mgmt *ql84_mgmt;
uint32_t sg_cnt; uint32_t sg_cnt;
uint32_t data_len; uint32_t data_len = 0;
uint32_t dma_direction = DMA_NONE; uint32_t dma_direction = DMA_NONE;
if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) || if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
...@@ -980,9 +980,11 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job) ...@@ -980,9 +980,11 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job)
} }
bsg_job->job_done(bsg_job); bsg_job->job_done(bsg_job);
dma_free_coherent(&ha->pdev->dev, data_len, mgmt_b, mgmt_dma);
done_unmap_sg: done_unmap_sg:
if (mgmt_b)
dma_free_coherent(&ha->pdev->dev, data_len, mgmt_b, mgmt_dma);
if (dma_direction == DMA_TO_DEVICE) if (dma_direction == DMA_TO_DEVICE)
dma_unmap_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list, dma_unmap_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list,
bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE); bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE);
......
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