scsi: ibmvscsis: Clean up properly if target_submit_cmd/tmr fails
authorMichael Cyr <mikecyr@us.ibm.com>
Thu, 13 Oct 2016 16:02:41 +0000 (11:02 -0500)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 8 Nov 2016 22:29:54 +0000 (17:29 -0500)
Signed-off-by: Michael Cyr <mikecyr@us.ibm.com>
Signed-off-by: Bryant G. Ly <bryantly@linux.vnet.ibm.com>
Tested-by: Steven Royer <seroyer@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c

index 41af435a8943e1b5a7c7b8426d71d07c10c57144..cd9f5c734018193e4db8e68b0c1b54f8e2c60e7a 100644 (file)
@@ -2560,6 +2560,10 @@ static void ibmvscsis_parse_cmd(struct scsi_info *vscsi,
                               data_len, attr, dir, 0);
        if (rc) {
                dev_err(&vscsi->dev, "target_submit_cmd failed, rc %d\n", rc);
+               spin_lock_bh(&vscsi->intr_lock);
+               list_del(&cmd->list);
+               ibmvscsis_free_cmd_resources(vscsi, cmd);
+               spin_unlock_bh(&vscsi->intr_lock);
                goto fail;
        }
        return;
@@ -2639,6 +2643,9 @@ static void ibmvscsis_parse_task(struct scsi_info *vscsi,
                if (rc) {
                        dev_err(&vscsi->dev, "target_submit_tmr failed, rc %d\n",
                                rc);
+                       spin_lock_bh(&vscsi->intr_lock);
+                       list_del(&cmd->list);
+                       spin_unlock_bh(&vscsi->intr_lock);
                        cmd->se_cmd.se_tmr_req->response =
                                TMR_FUNCTION_REJECTED;
                }