[SCSI] be2iscsi: Fix scsi_cmnd leakage in driver.
authorJayamohan Kallickal <jayamohan.kallickal@emulex.com>
Wed, 29 Jan 2014 07:16:44 +0000 (02:16 -0500)
committerJames Bottomley <JBottomley@Parallels.com>
Sat, 15 Mar 2014 17:19:11 +0000 (10:19 -0700)
scsi_cmnd n io_task was not NULL when
 - Link goes down while IO was happening and session is closed.
 - Task for which TMF was sent.

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@Parallels.com>
drivers/scsi/be2iscsi/be_main.c

index b1b6e74e0b7c4f2c5e73f466bd21f3a523d150ad..7b2bd16c81563fba3399ee18965b97aaa7de292a 100644 (file)
@@ -1366,8 +1366,10 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn,
        resid = csol_cqe->res_cnt;
 
        if (!task->sc) {
-               if (io_task->scsi_cmnd)
+               if (io_task->scsi_cmnd) {
                        scsi_dma_unmap(io_task->scsi_cmnd);
+                       io_task->scsi_cmnd = NULL;
+               }
 
                return;
        }
@@ -1404,6 +1406,7 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn,
                conn->rxdata_octets += resid;
 unmap:
        scsi_dma_unmap(io_task->scsi_cmnd);
+       io_task->scsi_cmnd = NULL;
        iscsi_complete_scsi_task(task, exp_cmdsn, max_cmdsn);
 }
 
@@ -4653,6 +4656,11 @@ static void beiscsi_cleanup_task(struct iscsi_task *task)
                        spin_unlock(&phba->io_sgl_lock);
                        io_task->psgl_handle = NULL;
                }
+
+               if (io_task->scsi_cmnd) {
+                       scsi_dma_unmap(io_task->scsi_cmnd);
+                       io_task->scsi_cmnd = NULL;
+               }
        } else {
                if (!beiscsi_conn->login_in_progress)
                        beiscsi_free_mgmt_task_handles(beiscsi_conn, task);