[stgt] [PATCH V1 10/13] spc: fix data-in buffer generation for REQUEST_SENSE cmd
nezhinsky at gmail.com
nezhinsky at gmail.com
Tue Feb 12 15:49:25 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 | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/usr/spc.c b/usr/spc.c
index a80820b..aeb022a 100644
--- a/usr/spc.c
+++ b/usr/spc.c
@@ -1619,17 +1619,17 @@ 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 = spc_memcpy(scsi_get_in_buffer(cmd), &alloc_len,
+ cmd->sense_buffer, cmd->sense_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