target:fix the cmd size in passthrough_parse_cdb
diff mbox

Message ID 1499483744-10084-1-git-send-email-tang.wenji@zte.com.cn
State New, archived
Headers show

Commit Message

tang.wenji@zte.com.cn July 8, 2017, 3:15 a.m. UTC
From: Tang Wenji <tang.wenji@zte.com.cn>

The cmd size should be 4bytes form byte5 to byte8 when CDB opcode is PERSISTENT_RESERVE_OUT in SPC3 and SPC4

Signed-off-by: Tang Wenji <tang.wenji@zte.com.cn>
---
 drivers/target/target_core_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mike Christie July 8, 2017, 5:48 a.m. UTC | #1
On 07/07/2017 10:15 PM, tang.wenji@zte.com.cn wrote:
> From: Tang Wenji <tang.wenji@zte.com.cn>
> 
> The cmd size should be 4bytes form byte5 to byte8 when CDB opcode is PERSISTENT_RESERVE_OUT in SPC3 and SPC4
> 
> Signed-off-by: Tang Wenji <tang.wenji@zte.com.cn>
> ---
>  drivers/target/target_core_device.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
> index 1c7c57a..e8dd6da 100644
> --- a/drivers/target/target_core_device.c
> +++ b/drivers/target/target_core_device.c
> @@ -1183,7 +1183,7 @@ passthrough_parse_cdb(struct se_cmd *cmd,
>  		}
>  		if (cdb[0] == PERSISTENT_RESERVE_OUT) {
>  			cmd->execute_cmd = target_scsi3_emulate_pr_out;
> -			size = get_unaligned_be16(&cdb[7]);
> +			size = get_unaligned_be32(&cdb[5]);
>  			return target_cmd_size_check(cmd, size);
>  		}
>

We should fix spc_parse_cdb() too.

I think maybe it would be best to take the common PGR and
reserve/release commands and put them in a helper, and it could be
called here and in spc_parse_cdb().
--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Nicholas A. Bellinger July 10, 2017, 3:55 a.m. UTC | #2
On Sat, 2017-07-08 at 11:15 +0800, tang.wenji@zte.com.cn wrote:
> From: Tang Wenji <tang.wenji@zte.com.cn>
> 
> The cmd size should be 4bytes form byte5 to byte8 when CDB opcode is PERSISTENT_RESERVE_OUT in SPC3 and SPC4
> 
> Signed-off-by: Tang Wenji <tang.wenji@zte.com.cn>
> ---
>  drivers/target/target_core_device.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
> index 1c7c57a..e8dd6da 100644
> --- a/drivers/target/target_core_device.c
> +++ b/drivers/target/target_core_device.c
> @@ -1183,7 +1183,7 @@ passthrough_parse_cdb(struct se_cmd *cmd,
>  		}
>  		if (cdb[0] == PERSISTENT_RESERVE_OUT) {
>  			cmd->execute_cmd = target_scsi3_emulate_pr_out;
> -			size = get_unaligned_be16(&cdb[7]);
> +			size = get_unaligned_be32(&cdb[5]);
>  			return target_cmd_size_check(cmd, size);
>  		}
>  


Applied, and fixed in spc_parse_cdb() too as mentioned by MNC.

Thank you.

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index 1c7c57a..e8dd6da 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -1183,7 +1183,7 @@  passthrough_parse_cdb(struct se_cmd *cmd,
 		}
 		if (cdb[0] == PERSISTENT_RESERVE_OUT) {
 			cmd->execute_cmd = target_scsi3_emulate_pr_out;
-			size = get_unaligned_be16(&cdb[7]);
+			size = get_unaligned_be32(&cdb[5]);
 			return target_cmd_size_check(cmd, size);
 		}