iscsi-target: Fix reject release handling in iscsit_free_cmd()
[firefly-linux-kernel-4.4.55.git] / drivers / target / iscsi / iscsi_target_util.c
index a05ca1c4f01c3c724992f07baa2a7505977b94f2..11287e1ece134190b6541bdb2bea45a236e46515 100644 (file)
@@ -849,6 +849,17 @@ void iscsit_free_cmd(struct iscsi_cmd *cmd)
        case ISCSI_OP_SCSI_TMFUNC:
                transport_generic_free_cmd(&cmd->se_cmd, 1);
                break;
+       case ISCSI_OP_REJECT:
+               /*
+                * Handle special case for REJECT when iscsi_add_reject*() has
+                * overwritten the original iscsi_opcode assignment, and the
+                * associated cmd->se_cmd needs to be released.
+                */
+               if (cmd->se_cmd.se_tfo != NULL) {
+                       transport_generic_free_cmd(&cmd->se_cmd, 1);
+                       break;
+               }
+               /* Fall-through */
        default:
                iscsit_release_cmd(cmd);
                break;