be2iscsi : Fix memory check before unmapping.
authorJohn Soni Jose <sony.john-n@emulex.com>
Sat, 25 Apr 2015 02:47:45 +0000 (08:17 +0530)
committerJames Bottomley <JBottomley@Odin.com>
Mon, 25 May 2015 15:46:32 +0000 (08:46 -0700)
 Check DMA memory before it is unmapped.

Signed-off-by: John Soni Jose <sony.john-n@emulex.com>
Signed-off-by: Jayamohan Kallickal <jayamohan.kallickal@emulex.com>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <JBottomley@Odin.com>
drivers/scsi/be2iscsi/be_main.c

index 7212bb47c0750e265499334b7033dcad798ebf39..65108370bfef3ced669d6357d94db075c0503448 100644 (file)
@@ -1368,8 +1368,10 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn,
        if (io_task->cmd_bhs->iscsi_hdr.flags & ISCSI_FLAG_CMD_READ)
                conn->rxdata_octets += resid;
 unmap:
-       scsi_dma_unmap(io_task->scsi_cmnd);
-       io_task->scsi_cmnd = NULL;
+       if (io_task->scsi_cmnd) {
+               scsi_dma_unmap(io_task->scsi_cmnd);
+               io_task->scsi_cmnd = NULL;
+       }
        iscsi_complete_scsi_task(task, exp_cmdsn, max_cmdsn);
 }
 
@@ -4609,11 +4611,13 @@ beiscsi_free_mgmt_task_handles(struct beiscsi_conn *beiscsi_conn,
                spin_unlock_bh(&phba->mgmt_sgl_lock);
        }
 
-       if (io_task->mtask_addr)
+       if (io_task->mtask_addr) {
                pci_unmap_single(phba->pcidev,
                                 io_task->mtask_addr,
                                 io_task->mtask_data_count,
                                 PCI_DMA_TODEVICE);
+               io_task->mtask_addr = 0;
+       }
 }
 
 /**