On 08/12/2011 06:55 PM, Peter Maydell wrote:
Does it still make sense to set req->cmd to cmd (and to look at cmd
at all) in the case where scsi_req_parse() failed and might not have
actually initialised all of cmd? For instance the tracing code (added
to scsi_req_new() after this patch) looks at cmd.buf[] based on the
value of buf[0], which seems kind of fragile to me.

At the point tracing is reached, we know that cmd.buf[] has been initialized. But you're right that it is at least not tidy.

We know that the size of the cdb is 16 (it is always like that, and we can make it a requirement). So we can copy it to cmd->buf before knowing cmd->len, at the beginning of scsi_req_parse. We can also zero unconditionally len/xfer/mode (plus set lba to -1) in case the parsing fails.

Paolo

Reply via email to