[stgt] [PATCH 10/13] spc: fix data-in buffer generation for REQUEST_SENSE cmd
nezhinsky at gmail.com
nezhinsky at gmail.com
Wed Jan 16 10:01:50 CET 2013
From: Alexander Nezhinsky <nezhinsky at gmail.com>
Fix allocation len extraction from CDB. Calculate and set the actual
transfer len correctly.
Signed-off-by: Alexander Nezhinsky <nezhinsky at gmail.com>
---
usr/spc.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/usr/spc.c b/usr/spc.c
index 646b50c..26ec364 100644
--- a/usr/spc.c
+++ b/usr/spc.c
@@ -1608,16 +1608,19 @@ int spc_access_check(struct scsi_cmd *cmd)
int spc_request_sense(int host_no, struct scsi_cmd *cmd)
{
uint8_t *data;
- uint32_t len;
+ uint32_t alloc_len, actual_len;
data = scsi_get_in_buffer(cmd);
- len = scsi_get_in_length(cmd);
+
+ alloc_len = (uint32_t)cmd->scb[4];
+ alloc_len = min_t(uint32_t, alloc_len, scsi_get_in_length(cmd));
sense_data_build(cmd, NO_SENSE, NO_ADDITIONAL_SENSE);
- memcpy(data, cmd->sense_buffer, min_t(uint32_t, len, cmd->sense_len));
+ actual_len = min_t(uint32_t, alloc_len, cmd->sense_len);
+ memcpy(data, cmd->sense_buffer, actual_len);
- scsi_set_in_resid_by_actual(cmd, cmd->sense_len);
+ scsi_set_in_resid_by_actual(cmd, actual_len);
/* reset sense buffer in cmnd */
memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer));
--
1.7.9.6
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
More information about the stgt
mailing list