From: Andy Grover Date: Thu, 3 Sep 2015 23:03:44 +0000 (-0700) Subject: target/user: Fix UFLAG_UNKNOWN_OP handling X-Git-Tag: v4.1.12-105.0.20170622_2100~31 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=fd7aa504ee5a626b1db64ab64c620cf70948e6f3;p=users%2Fjedix%2Flinux-maple.git target/user: Fix UFLAG_UNKNOWN_OP handling Calling transport_generic_request_failure() from here causes list corruption. We should be using target_complete_cmd() instead. Which we do in all other cases, so the UNKNOWN_OP case can become just another member of the big else/if chain in tcmu_handle_completion(). Signed-off-by: Andy Grover Signed-off-by: Nicholas Bellinger Orabug: 25395066 (cherry picked from commit ed97d0cd78a337450e17eb613bdeec15e729af46) Signed-off-by: Kyle Fortin Reviewed-by: Shan Hai --- diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index e22330fa7189..0fd564ef4c8a 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -536,14 +536,8 @@ static void tcmu_handle_completion(struct tcmu_cmd *cmd, struct tcmu_cmd_entry * UPDATE_HEAD(udev->data_tail, cmd->data_length, udev->data_size); pr_warn("TCMU: Userspace set UNKNOWN_OP flag on se_cmd %p\n", cmd->se_cmd); - transport_generic_request_failure(cmd->se_cmd, - TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE); - cmd->se_cmd = NULL; - kmem_cache_free(tcmu_cmd_cache, cmd); - return; - } - - if (entry->rsp.scsi_status == SAM_STAT_CHECK_CONDITION) { + entry->rsp.scsi_status = SAM_STAT_CHECK_CONDITION; + } else if (entry->rsp.scsi_status == SAM_STAT_CHECK_CONDITION) { memcpy(se_cmd->sense_buffer, entry->rsp.sense_buffer, se_cmd->scsi_sense_length);