Fix scst_local crash on 0 response data len w/o data buffer allocated

+ some related cleanups

Reported by Richard Sharpe <realrichardsharpe@gmail.com>



git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4512 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2012-09-11 18:42:42 +00:00
parent d8b5dd28b4
commit a2825d8b06
2 changed files with 5 additions and 3 deletions

View File

@@ -1498,7 +1498,8 @@ static int dev_user_process_reply_exec(struct scst_user_cmd *ucmd,
* We have an empty SG, so can't call
* scst_set_resp_data_len()
*/
cmd->resp_data_len = ereply->resp_data_len;
WARN_ON(ereply->resp_data_len != 0);
cmd->resp_data_len = 0;
cmd->resid_possible = 1;
} else
scst_set_resp_data_len(cmd, ereply->resp_data_len);

View File

@@ -5987,13 +5987,14 @@ void scst_copy_sg(struct scst_cmd *cmd, enum scst_sg_copy_dir copy_dir)
} else {
src_sg = cmd->sg;
dst_sg = cmd->tgt_i_sg;
to_copy = cmd->resp_data_len;
to_copy = cmd->adjusted_resp_data_len;
}
TRACE_MEM("cmd %p, copy_dir %d, src_sg %p, dst_sg %p, to_copy %lld",
cmd, copy_dir, src_sg, dst_sg, (long long)to_copy);
if (unlikely(src_sg == NULL) || unlikely(dst_sg == NULL)) {
if (unlikely(src_sg == NULL) || unlikely(dst_sg == NULL) ||
unlikely(to_copy == 0)) {
/*
* It can happened, e.g., with scst_user for cmd with delay
* alloc, which failed with Check Condition.