aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/target_core_spc.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
index 803339516fb9..4cb667d720a7 100644
--- a/drivers/target/target_core_spc.c
+++ b/drivers/target/target_core_spc.c
@@ -1000,6 +1000,14 @@ static sense_reason_t spc_emulate_modeselect(struct se_cmd *cmd)
1000 int ret = 0; 1000 int ret = 0;
1001 int i; 1001 int i;
1002 1002
1003 if (!cmd->data_length) {
1004 target_complete_cmd(cmd, GOOD);
1005 return 0;
1006 }
1007
1008 if (cmd->data_length < off + 2)
1009 return TCM_PARAMETER_LIST_LENGTH_ERROR;
1010
1003 buf = transport_kmap_data_sg(cmd); 1011 buf = transport_kmap_data_sg(cmd);
1004 if (!buf) 1012 if (!buf)
1005 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; 1013 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
@@ -1024,6 +1032,11 @@ static sense_reason_t spc_emulate_modeselect(struct se_cmd *cmd)
1024 goto out; 1032 goto out;
1025 1033
1026check_contents: 1034check_contents:
1035 if (cmd->data_length < off + length) {
1036 ret = TCM_PARAMETER_LIST_LENGTH_ERROR;
1037 goto out;
1038 }
1039
1027 if (memcmp(buf + off, tbuf, length)) 1040 if (memcmp(buf + off, tbuf, length))
1028 ret = TCM_INVALID_PARAMETER_LIST; 1041 ret = TCM_INVALID_PARAMETER_LIST;
1029 1042