Commit 934a138e authored by Nicholas Bellinger's avatar Nicholas Bellinger

target: Make target_do_xcopy failures return INVALID_PARAMETER_LIST

This patch changes target_do_xcopy() to properly return
TCM_INVALID_PARAMETER_LIST instead of TCM_INVALID_CDB_FIELD
for failures related to the EXTENDED_COPY parameter list parsing.

Also, move struct xcopy_op allocation ahead of kmapping to
handle the special TCM_OUT_OF_RESOURCES case.
Reported-by: default avatarThomas Glanzmann <thomas@glanzmann.de>
Reported-by: default avatarDouglas Gilbert <dgilbert@interlog.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent 9e20ae33
...@@ -896,9 +896,17 @@ sense_reason_t target_do_xcopy(struct se_cmd *se_cmd) ...@@ -896,9 +896,17 @@ sense_reason_t target_do_xcopy(struct se_cmd *se_cmd)
return TCM_UNSUPPORTED_SCSI_OPCODE; return TCM_UNSUPPORTED_SCSI_OPCODE;
} }
xop = kzalloc(sizeof(struct xcopy_op), GFP_KERNEL);
if (!xop) {
pr_err("Unable to allocate xcopy_op\n");
return TCM_OUT_OF_RESOURCES;
}
xop->xop_se_cmd = se_cmd;
p = transport_kmap_data_sg(se_cmd); p = transport_kmap_data_sg(se_cmd);
if (!p) { if (!p) {
pr_err("transport_kmap_data_sg() failed in target_do_xcopy\n"); pr_err("transport_kmap_data_sg() failed in target_do_xcopy\n");
kfree(xop);
return TCM_OUT_OF_RESOURCES; return TCM_OUT_OF_RESOURCES;
} }
...@@ -920,13 +928,6 @@ sense_reason_t target_do_xcopy(struct se_cmd *se_cmd) ...@@ -920,13 +928,6 @@ sense_reason_t target_do_xcopy(struct se_cmd *se_cmd)
goto out; goto out;
} }
xop = kzalloc(sizeof(struct xcopy_op), GFP_KERNEL);
if (!xop) {
pr_err("Unable to allocate xcopy_op\n");
goto out;
}
xop->xop_se_cmd = se_cmd;
pr_debug("Processing XCOPY with list_id: 0x%02x list_id_usage: 0x%02x" pr_debug("Processing XCOPY with list_id: 0x%02x list_id_usage: 0x%02x"
" tdll: %hu sdll: %u inline_dl: %u\n", list_id, list_id_usage, " tdll: %hu sdll: %u inline_dl: %u\n", list_id, list_id_usage,
tdll, sdll, inline_dl); tdll, sdll, inline_dl);
...@@ -957,7 +958,7 @@ sense_reason_t target_do_xcopy(struct se_cmd *se_cmd) ...@@ -957,7 +958,7 @@ sense_reason_t target_do_xcopy(struct se_cmd *se_cmd)
if (p) if (p)
transport_kunmap_data_sg(se_cmd); transport_kunmap_data_sg(se_cmd);
kfree(xop); kfree(xop);
return TCM_INVALID_CDB_FIELD; return TCM_INVALID_PARAMETER_LIST;
} }
static sense_reason_t target_rcr_operating_parameters(struct se_cmd *se_cmd) static sense_reason_t target_rcr_operating_parameters(struct se_cmd *se_cmd)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment